[Previous]   [Next]   [Contents]   [Index]   

Using Java Applications

HP Netstation Software 9.0 includes a Java Runtime Environment (JRE) that lets you run any Java program that conforms to the 100% Pure Java specification.

For more information about how to use the Java Runtime Environment, refer to the following sections:

About the HP Netstation Java Runtime Environment

The HP Netstation Java Runtime Environment provides the facilities for you to run any Java program (application or applet) that conforms to the 100% Pure Java specification.

You can run third-party Java programs or develop your own. To develop your own Java programs, you need a Java Development Kit, such as the JDK 1.1.2 for HP-UX.

For information about Java products in general, open the following location from a web browser: www.javasoft.com.

Configuring the Java Runtime Environment

For every Netstation that will run Java programs, review the following configuration steps.

  1. If you have changed the Netstation configuration defaults, ensure that remote configuration is enabled. See Changing the Configuration Methods for details. (By default, remote configuration is enabled.)

  2. If the Netstation already has a remote configuration file (from a previous release of HP Netstation Software), add the following line:
    include $(NsRoot)/Java_1.1.2/config/java.cfg
    

    By default, this line is included in HP Netstation Software 9.0 remote configuration files.

    For more information about remote configuration, see Using Remote Configuration.

  3. If the Netstation already has a directives file (from a previous release of HP Netstation Software), add the following line:
    include $(NsRoot)/Java_1.1.2/bin/java.directives
    

    By default, this line is included in HP Netstation Software 9.0 directives files.

    For more information about directives files, see Customizing the directives File.

  4. If you have made any changes, reboot the Netstation.

Note: If you plan to run Java programs that require Java Database Connectivity (JDBC) drivers, you need to purchase the appropriate Type 4 JDBC driver for your database type. The HP Netstation Software includes the necessary JDBC interface. To purchase the Type 4 JDBC drivers for your database type, visit the following website:
http://www.javasoft.com/products/jdbc/jdbc.drivers.html

Launching a Java Program

There are several ways to launch a Java program through the HP Netstation Software Java Runtime Environment:

Depending upon which Java programs you plan to run and where they reside, you may want to run the JRE with or without a peer. For more information, refer to Deciding Whether to Use a Peer. By default, the JRE will run without a peer.

To see how the JRE operates, run one of the sample programs as listed in Running a Sample Java Program.

Deciding Whether to Use a Peer

You can invoke the JRE either with or without a peer (an intermediate process or companion helper application that can start local clients on the Netstation). The default is for the JRE to run without a peer. You may wish to change this default if:

When deciding whether or not to use a peer, consider the following information.

If you invoke the JRE with a peer:

If you invoke the JRE without a peer (this is the default):

Running a Sample Java Program

HP Netstation Software includes various sample Java programs. These programs are installed in /opt/hpxt/enware2/Java_1.1.2/demo. To run one of these programs, follow these steps:

  1. Set your path to include:
    /opt/hpxt/enware2/Java_1.1.2/hostbin
    

  2. Invoke the Java console by typing:
    hpxt.java

  3. Select the File menu.

  4. Select Start Java Applet.

  5. Type the path name for the selected sample applet. For example, type:
    /opt/hpxt/enware2/Java_1.1.2/demo/TicTacToe/example1.html
    

Starting a Java Program from the Command Line

To start a Java program (application or applet) from the command line, do the following:

  1. If you have not already done so, add /opt/hpxt/enware2/Java_1.1.2/hostbin to the PATH environment variable.

  2. Enter one of the following commands:
    hpxt.java [java_args] [classname [class_args] ]
    hpxt.appletviewer [applet_args] filename [appletviewer_args]
    hpxt.java_peer [java_args] [classname [class_args] ]
    hpxt.appletviewer_peer [applet_args] filename [appletviewer_args]
    

    where:

    Command
    Purpose
    hpxt.java
    Starts an application or applet
    hpxt.appletviewer
    Starts an applet
    _peer scripts
    Start the JRE with a peer (the other scripts start the JRE without a peer).

    For information about the other invocation options, access the following man pages:

    A Word About Class Paths

    The JRE searches for class files in the following directories:

    1. First, the JRE searches the default class path:
      /opt/hpxt/enware2/Java_1.1.2/lib/classes.zip
      /opt/hpxt/enware2/Java_1.1.2/lib/classes
      /opt/hpxt/enware2/Java_1.1.2/user_java/lib/classes.zip
      /opt/hpxt/enware2/Java_1.1.2/user_java/lib/classes
      

      To override this default, and not use the default class path at all, use the -nodefault option.

    2. Next, it searches any directories specified in the -classpath option.

    3. If you do not use the -classpath option, it searches the directories specified in the CLASSPATH environment variable.

Starting a Java Program from a Local Window Manager

From any of the supported local window managers, you can start a Java program (application or applet) as follows:

From the Root Background Menu:

  1. Move the mouse cursor to the screen background.

  2. Hold down the left mouse button. The Workspace Menu appears.

  3. Drag the cursor to the Local Clients entry.

  4. Select one of the following:

From the Control Panel

You can also customize your local window manager to add these choices to the control panel menus. For example, to add these menu choices to your CDE Lite menus, follow the instructions in the following man pages:

Starting a Java Program from the Java Console

If you invoke hpxt.java (or hpxt.java_peer) without specifying a class name, the console window appears.


Java Console

To start an application, select the File menu, then Start Java Application. If you are not sure of the name of the application, select the File menu and then Browse to search for application names.

To change the default behavior of the console, refer to:

Changing Console Show/Noshow Defaults

When you start a Java application or applet, the Java console normally runs in the background. It appears when it is needed (when the application attempts to read from stdin or write to stdout or stderr).

You can override this default using the following options:

Hiding the Console Screen

If you want to make the console disappear, select File then Hide Console. To bring the console screen back, see Re-displaying the Console Screen.

Re-displaying the Console Screen

To bring the console screen back into view, follow these steps:

In most window managers, you can also select the small horizontal bar icon in the upper left corner of the Java window and then select Show Java Console.

Adding an Application

You can develop your own applications or acquire them from third parties. In either case, you make the application available to your users as follows:

  1. Install the class files, and any other necessary files, in either of the following directories:

    You would usually install large applications with complicated class hierarchies in their own directories.

  2. If you want users to be able to invoke the application from the root menu, add the appropriate line to the following file:
    /opt/hpxt/enware2/Java_1.1.2/bin/user_java.directives
    

    For more information about the syntax used in this file, see the /opt/hpxt/enware2/xthome/bin/directives file.

Printing from Within Java Applications

If you want to print from within a Java application, you need to ensure that you have configured the printer to work with your Netstation. For details, refer to Using LPR and LPD to Set Up Printing.

Developing Applications for the Java Runtime Environment

This section is intended for programmers who develop Java applications to run on HP Netstations. The key features of this Java Runtime Environment are:

For information about the Netstation-specific classes, open the following file from a web browser:

/opt/hpxt/enware2/Java_1.1.2/doc/html/NETSTATIONProcess.html

For information about other classes, open the following location from a web browser:

http://java.sun.com/products/jdk/1.1/docs/api/packages.html

Troubleshooting the Java Runtime Environment

This section provides suggested actions to solve problems that may occur when you use the HP Netstation Java Runtime Environment. Topics include:

Verifying the Correct Configuration

If you are unable to run your specific Java program, the first step in diagnosing the problem is to determine whether you can run any Java program. For instructions on how to run a sample Java program, refer to Running a Sample Java Program. If the sample program executes successfully, the HP Netstation Software Java Runtime Environment is working correctly. In this case, the problem is most likely with the Classpath setting. For details, refer to CLASS NOT FOUND errors.

Can't Run Java Applications

If the Java Virtual Machine (JVM) does not load, you will be unable to run any Java programs. If this is the case, the most likely cause is that the shared library path is not set properly. Check the Terminal Log in the configuration screens (Choose Diagnostic then Log).

CLASS NOT FOUND errors

If the error message you receive indicates a CLASS NOT FOUND error, the most likely cause is an error with the Classpath setting. To find out where the Netstation was searching, try running the same command using verbose mode. For example, from the command line type:
hpxt.java [classname] -v Java program
where:

You can change the Classpath setting in the following ways:

Can't Find java/lang/Thread

If you receive a message indicating that the Java Runtime Environment cannot find class java/lang/Thread, the problem is most likely that you are running the Java Runtime Environment with a peer, and that the peer is running on a host that does not have the HP Netstation Software Java files installed.

To resolve this problem, you can:

Security Violation errors

Security violation errors may occur if:

To resolve these security violation errors, you should run the Java Runtime Environment with a peer. For more information, see Deciding Whether to Use a Peer.

If you decide that you want to override the security violation errors, you can reset the permissions in:

/opt/hpxt/enware2/Java_1.1.2/lib/appletviewer.properties

[Previous]   [Next]   [Contents]   [Index]