Appendix C Creating Jaguar 1.1 Java Clients


Compile and run the Java client

This section shows you how to use Javasoft's JDK to compile and run your Java client. If you are using another Java development tool, see its documentation for information about how to compile and run your Java client.

Compiling the applet or Java application

Before you compile your applet or Java application, make sure that these paths are specified by the CLASSPATH environment variable:

To compile your Java client using the JDK, enter this command:

javac java_program.java

javac is the command to invoke the Java compiler.

java_program is the name of your Java application or applet.

For example, to compile the StockTest.java Java application, enter this command:

javac StockTest.java

Run the applet

To run the applet, place it in the appropriate directory on the server and create a test HTML page from which to run your applet. You must include the applet HTML tag on the test page.

  1. Create a text file, called test.html, with this text:
    <HTML>
    <HEAD>
    <TITLE>Applet Test Page
    </TITLE>
    </HEAD>
    <BODY>
    <P>This HTML page runs an applet.
    </P>
    <APPLET CODE="MyApplet.class" CODEBASE="/classes" WIDTH=500 HEIGHT=500>
    </APPLET>
    </BODY>
    </HTML>

    CODEBASE specifies the path to MyApplet.class. If the applet is in the same directory as the HTML page, you do not have to specify CODEBASE . The path specified in CODEBASE is relative to the Jaguar server's document root (the default is $JAGUAR/html). The forward slash (/) must begin the CODEBASE . The applet cannot be compressed.

    All classes that are required to run the applet must be in the directory path specified by CODEBASE .

    MyApplet is the name of the applet. If the applet belongs to a package, you must specify the package name as well. For example, if the applet, JagApp.class, belongs to the Animals.Cats package, then CODE would be specified as:
    CODE="Animals/Cats/JagApp.class"

  2. On the server machine, make sure these paths exist under $JAGUAR/html/CODEBASE :
    The Java classes in these directories cannot be compressed.
  3. To run the applet, display test.html in a Java-enabled browser, the applet viewer, or any other HTML previewer that comes with your JDK.

Run the Java application

Use the JDK Java interpreter to run the Java application.

Before you run your Java application, make sure that these paths are specified by the CLASSPATH environment variable:

In a UNIX shell or in a Windows console window, enter this command to run a Java application with the Java interpreter:

java java_application

where:

java is the command to invoke the Java interpreter.

java_application is the name of your Java application.

For example, to run the StockTest.class Java application, enter this command:

java StockTest

Required classes

If you deploy a client applet on a different Web server than Jaguar, or if you deploy a client application to a different host (other than the host where Jaguar is installed), you must ensure that your client program has access to the required Java classes. Required Java packages are listed below.

In addition to the classes that implement your client program, you must ensure that the classes below are deployed with your applet or application.

 


Copyright © 2000 Sybase, Inc. All rights reserved.