Previous | Next | Trail Map | Getting Started


The "run:" Protocol Handler

Note: This page reflects the 1.0 Alpha 3 release of HotJava and Java. It will be updated for the Beta release of HotJava.

By following the steps on this page, you can create and use a protocol handler. When you've followed all the steps, your directory (folder) structure should look something like this:

Create directories

Create the directory structure shown in the figure above: classes/net/www/protocol/run.

By convention, the directory structure starts with a directory named classes. The next three directories must be named as shown (net/www/protocol). The final directory must have the same name as the protocol (without the trailing ':'); in this case, this is run.

Create a Java source file for the protocol handler

In the run directory, create a file named Handler.java with these contents. This file defines a class named Handler that's a subclass of URLStreamHandler (a class in the net.www.html package).

Put an applet in the classes directory

Put an applet in the same directory as the net directory you just created (see the figure above). You can use the HelloWorld applet, saving the source code in a file named HelloWorld.java.

Compile the Java source files

Compile the protocol handler and applet using the Java compiler.

If compilation succeeds, the compiler creates a file named Handler.class for the protocol handler and HelloWorld.class for the applet. If compilation fails, make sure you typed in and named the programs exactly as shown above.

Set the CLASSPATH environment variable

Set the CLASSPATH environment variable to include the classes directory, so that HotJava can find the run protocol handler and the test program.

Start HotJava

Even if HotJava is already running, you need to restart it so that it can read the new value of the CLASSPATH environment variable.

Important: Do NOT invoke hotjava from the classes directory. Due to a bug, HotJava can't reload an applet (for example, after you make changes to its code) when you invoke hotjava from the directory that contains the applet's compiled code.

Load the protocol handler

Load the "run:" protocol handler and the applet, using a URL such as this:
run:HelloWorld
You should see the applet running in the page that appears.

Now what?

Now you can either:


Previous | Next | Trail Map | Getting Started