IBM Books

Open Host Interface Objects for Java


Building Open Host Interface Objects Applets

This section describes how to build a Java applet which uses the Open Host Interface Objects (OHIO). The source code preparation and compiling requirements are described.

Source Code Preparation

Programs that use OHIO classes must import the OHIO package to obtain class definitions and other compile-time information. The OHIO package can be imported into a Java source file using the following statement:

import org.ohio.*;

Note that work on defining the OHIO cross-vendor API has not completed at this time (see the "Introduction to the Open Host Interface Objects"). The OHIO Java package name could change.

Compiling

To compile the new Java source file, the CLASSPATH environment variable must be updated to include the directory containing the OHIO jar file. Another option is to use the '-classpath' parameter of the Java compiler to specify the location of the jar file.

HOD-uniqueIn Host On-Demand, the OHIO classes are contained in the habeans.jar file.

PComm-uniqueIn Personal Communications, the OHIO classes are contained in the pcseclj.jar file.

The CLASSPATH variable (or -classpath parameter) must contain the fully qualified pathname of the OHIO jar. For example, if the jar file is located in the c:\hod directory, the CLASSPATH should look like this:

CLASSPATH=c:\hod\habeans.jar;

Executing

When an applet that uses OHIO is run in a browser environment, the browser must be able to find the OHIO classes. Most browsers will search for java classes relative to the location specified by the 'codebase' tag in the 'applet' tag or, if no 'codebase' is specified, relative to the HTML document itself. See your browser documentation for more information on how to expose classes in the browser environment.

Alternatively, the jar file can be specified directly in the HTML document using the 'archive' tag in the 'applet' tag. For example:

<APPLET archive="habeans.jar" CODE="MyClass.class" WIDTH=400 HEIGHT=300></APPLET>

When running your program as an application, you need to make sure the CLASSPATH environment variable contains the fully qualified pathname of the OHIO jar.


[ Top of Page | Previous Page | Next Page | Table of Contents ]