cd <your-classes-directory> javac HelloWorld.java cd COM\foo\protocol\run javac Handler.java javac RunURLConnection.java

If compilation succeeds, the compiler creates files named Handler.class and RunURLConnection.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.

5.  Set the java.protocol.handler.pkgs property

In the HotJava Browser properties file, set the java.protocol.handler.pkgs property to include your new protocol package, COM.foo.protocol. This property is a vertical bar (|) separated list of package prefixes that defines a search path for protocol handlers.

See Customizing the HotJava Browser for information about where to find the properties file for your platform.

For this example, you would add the following line to your HotJava Browser properties file:

   java.protocol.handler.pkgs=COM.foo.protocol

If you have other protocol handlers defined, use a vertical bar (|) separated list as the value of the property. For example:

   java.protocol.handler.pkgs=COM.foo.protocol|other.protocol

6.  Set the CLASSPATH environment variable.

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

On UNIX systems, the method of setting environment variables depends on your shell. For C shell, you can enter something like the following at the shell prompt, or put it in your .cshrc file:

   setenv CLASSPATH .:/home/developer/classes

On Windows sytems, enter something like the following in a DOS shell, the Windows NT Control Panel, or your AUTOEXEC.BAT file:

   set CLASSPATH=.;C:\developer\classes

7.  Start the HotJava Browser

Even if the HotJava Browser is already running, you need to restart it so that it can read the new values of the java.protocol.handler.pkgs property and CLASSPATH environment variable.

8.  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 you can use your new protocol handler wherever you can specify a URL (e.g. links in HTML pages, in the URL typein field, etc.).


Back to HotJava User's Guide Table of Contents

Back to Content and Protocol Handlers

Back to Local Content Handlers (previous topic)

dt/appconfig/hotjava/UsersGuide/SATextOverlay.class010044400000000000002000000063730635531500600225220ustar00rootbin00000400000016-} C D D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` a b c d e f g ~m ~x ~y ~z ~| w t u q y r h i l n { v j h k p o x s k ()I()Ljava/awt/Color;()Ljava/awt/Dimension;()Ljava/lang/String;()Ljava/net/URL;()V'(Ljava/awt/Font;)Ljava/awt/FontMetrics;(Ljava/awt/Font;)V(Ljava/awt/Graphics;)VC(Ljava/awt/Image;IILjava/awt/Color;Ljava/awt/image/ImageObserver;)Z(Ljava/lang/Object;)Z(Ljava/lang/String;)I#(Ljava/lang/String;)Ljava/awt/Font;'(Ljava/lang/String;)Ljava/lang/Integer;&(Ljava/lang/String;)Ljava/lang/String;,(Ljava/lang/String;)Ljava/lang/StringBuffer;(Ljava/lang/String;)V(Ljava/lang/String;II)V'(Ljava/lang/String;Ljava/lang/String;)V (Ljava/net/URL;)Ljava/awt/Image;#(Ljava/net/URL;Ljava/lang/String;)V-Bad image URL: Code ConstantValue ExceptionsHelvetica-bold-24ILineNumberTableLjava/awt/Font;Ljava/awt/FontMetrics;Ljava/awt/Image;Ljava/lang/String;LocalVariables SATextOverlaySATextOverlay.java SourceFileZappendboldcenter centerFlagcenterXcenterY createNewFontdecodedefaultCenterXdefaultCenterY defaultFont defaultPosX defaultPosY drawImage drawStringequalsfont getAscent getBackgroundgetDocumentBasegetFontMetricsgetImage getParametergetSizeheightimageinitintValueitalicjava/applet/Appletjava/awt/Componentjava/awt/Dimension java/awt/Fontjava/awt/FontMetricsjava/awt/Graphicsjava/lang/Integerjava/lang/NumberFormatExceptionjava/lang/Stringjava/lang/StringBufferjava/net/MalformedURLException java/net/URLjava/util/StringTokenizermetrics nextToken overlayFontpaintplainposXposYposxposysetFont showStatus stringWidthtexttoStringupdatewidth!mz* 2L+4Y*/+"M**,15W*Y+#A>*2N--:**&9***907**9=* 2:!*,$*'6;W* 2:!*,%*'6<W**2@ !$ GJ K LM!K$N%O9K<TCUOWYXeYm\u^z_`a`b`gijklkmkrDp"*+: vup*5+*5*.**W*@*;=*<>*$*3B*7*@?dl=*3B*7*@?d`=*%*34*7-`l>*34*7-``>+*@+Fz{}~#(/EHLbi{~yt`Y+!M,8N6,8:, 6 ,6 ,6Y,866Y- 6 #&)36@CS~m^***;*<*(*)**($**)%"-; <>?A!B)-dt/appconfig/hotjava/UsersGuide/UGcontent.html010044400000000000002000000527660634666653200216010ustar00rootbin00000400000016 HotJava Browser User's Guide Index

Index: HotJava Browser User's Guide

A

actions
Ask user
Display in HotJava Browser
for displaying externalith a directory named classes. The next three directories, COM/foo/protocol, are used to create a package called COM.foo.protocol. The convention is to prefix packages produced by company fred.flintstone.COM with COM.flintstone.fred, so two different vendors creating the same class are unlikely to have name collisions.

The final directory must have the same name as the new protocol (without the trailing ':'). In this example, this is run. The only strict requirement about the directory structure is that the name of the protocol is the last part of the package name.

2.  Create the Java source file(s) 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 is a subclass of URLStreamHandler (a class in the java.net package). A protocol handler must be called Handler, and it must be a subclass of URLStreamHandler.

In the same directory, you'll also need to create a file named RunURLConnection.java with these contents.

3.  Put an applet in the classes directory.

You can use any applet that is reachable through your CLASSPATH environment variable. For the purposes of this example, put an applet in the classes directory. You can use the HelloWorld applet, saving the source code in a file named HelloWorld.java.

4.  Compile the Java source files.

Compile the protocol handler and applet using the Java compiler.

On UNIX systems:

    cd <your-classes-directory>
    javac HelloWorld.java 
    cd COM/foo/protocol/run
    javac Handler.java
    javac RunURLConnection.java

In a DOS shell (Windows 95/NT):