1.1 Changes: Java Archive (JAR) Files and Applets

You can provide all of an applet's class and data files in a single Java archive (JAR) file, using the JDK jar tool and the new ARCHIVE attribute of the <APPLET>. Using JAR files can improve an applet's performance in two ways:

To tell a browser about JAR files, use the new ARCHIVE attribute of the <APPLET> tag.

    [ARCHIVE = JARFile1, JARFile2, ...]
ARCHIVE = JARFile1, JARFile2, ...
This optional attribute specifies one or more Java archive (JAR) files associated with the applet. The archive files should be in the same directory the applet's class files would be. To specify that the archive file isn't in the same directory as the document containing the <APPLET> tag, specify the CODEBASE attribute.

Whenever a browser needs to load a file needed by an applet, the browser looks in the applet's JAR files first. If it doesn't find the file in the first JAR file specified with ARCHIVE, it looks any other specified JAR files, in the order they were specified. If the browser fails to find the file in a JAR file, then it looks in the applet's base directory. [Do we really guarantee that the JAR file specification order is the order in which the browser will look?]

Here's an example of creating and specifying a JAR file. Assume you have an applet that consists of two class files and an image file. You can create a JAR file that contains all three files. For example, on Solaris using the JDK, you might use this command:
jar cvf MyApplet.jar AnAppletSubclass.class Helper.class aPic.gif
You could then specify the JAR file to the browser using this <APPLET> tag:
    ARCHIVE = MyApplet.jar
    CODE = AnAppletSubclass.class
    WIDTH = 300
    HEIGHT = 100

Here's an example of a more complex <APPLET> tag that uses the ARCHIVE attribute:

        ARCHIVE="AppletButton.jar, IntlWindow.jar,  Media.jar"
        WIDTH=350 height=60
        ALT="Your browser understands the applet tag but isn't displaying any
<PARAM NAME="windowWidth" VALUE=500>
<PARAM NAME="windowHeight" VALUE=130>
Since you can't run the applet, here's a picture of it:
<IMG SRC="images/AroundTheWorld_trans.gif" WIDTH=316 HEIGHT=411>