Previous ION Java User's Guide: Building ION Applets and Applications Next

Compiling .java Files

Keep the following points in mind when you compile the .java file that contains your applet or application code.

Setting the Class Path

When you compile an ION applet or application, the ION class files must be in the Java compiler's class path. Since ION is a package, the class files are stored in a directory structure. The ION class files are located in the following ION installation subdirectory of the classes directory:

Root_ION/com/itt/ion   

Where Root_ION indicates the path to the classes directory. If you have installed ION in the default directory, Root_ION would be:

On UNIX:  
/usr/local/itt/ion64/ion_java/classes  
  
On Windows:  
C:\Program Files\ITT\idl64\products\ion64\ion_java\classes  

Depending on your specific Java compiler, this can be accomplished by defining the system CLASSPATH environment variable. See Setting the Class Path Environment Variable for more information. However, the recommended method is to specify the class path on the command line when you are compiling your program. See the following section for more information.

Setting the Class Path When Compiling

Because browsers react differently to a class path system definition, another way to specify the class path is to specify the ION path on the command line when you compile your Java program. If you have installed ION in the default directory, this might be similar to one of the following:

On UNIX:  
javac -classpath .:/usr/local/itt/ion64/ion_java/classes 
   myIonApp.java  
  
On Windows:  
javac -classpath 
"C:\Program Files\ITT\idl64\products\ion64\ion_java\classes" 
   myIonApp.java  

This method of specifying the class path has the added benefit of simulating the same environment that your clients will experience when running your application from your browser. This method does not rely on having a system environment variable pointing to the ION classes directory, something your clients are unlikely to have defined.

Setting the Class Path Environment Variable

To define the CLASSPATH environment variable, you would set it using the following shell command on UNIX:

setenv CLASSPATH .:/usr/local/itt/ion64/ion_java/classes  

or modify the class path environment variable in the System Environment dialog on Windows. The Java compiler will add the com/itt/ion portion of the path when it looks for the package.

Once the CLASSPATH is set, you can compile your code with a shell command like the following:

javac myIONApp.java  

where myIONApp is the name of your applet or application.


Warning
If you are running the client and the server on the same machine, setting the system CLASSPATH environment variable can result in errors similar to the following, appearing in your browser's Java console:

    Netscape Java Console — #Applet exception:         error.java.lang.ClassFormatError:class already loaded
    IE Java Console — Error getting package information: com/itt/ion

To avoid such errors, specify the class path when compiling as described in the previous section.

  IDL Online Help (March 06, 2007)