Use a JAR/ZIP/CAB file with an Applet (this howto is deprecated)Tag(s): DEPRECATED
[JAR format]
JAR (Java ARchive) is a platform-independent file format that allows you
to bundle a Java applet and its requisite components (.class files,
images and sounds) into a single JAR file. JAR supports compression,
which reduces the file size, further improving the download time.
The applet author can digitally sign individual entries in a JAR file to authenticate their origin (using the JAVAKEY utility). However, to sign JAR to be used with a "real-world" browser (eg. Netscape), you must use Netscape's utilities ZIGbert or GUI JAR Archiver to sign it. These utilities can be freely downloaded from the Netscape Web site. For more infos about signing Applet for Netscape, check this JAVA How-to.
The browser need to be JDK1.1 compatible to handle JAR file.
If a JAR file is used with an Applet, the browser will look first into the JAR to load all classes. If the search fails in the JAR file, then the browser looks in the applet's base directory. To specify the use of a JAR file with an applet:
<APPLET CODE=a.class ARCHIVE="abc.jar" WIDTH=100 HEIGHT=100> </APPLET>
Microsoft IEv4 can handle multiple JAR files.
In an application, simply include the JAR in the CLASSPATH :
java -classpath c:\jdk1.1.3\lib\classes.zip;.;.\HelloWorld.jar HelloWorld
To create a JAR file (compressed), use the JAR utility included with JDK1.1
jar cvf abc.jar a.class b.class c.class
jar cvfO myArchive.jar *.class
[ZIP format]
JDK1.0.2 introduces the ZIP "un-compressed" format. To create
an archive, simply use a ZIP tool that supports the long filename
format and specify the ZERO compression mode. You can use
Sun's JAR utility (included with JDK1.1) to create a JDK1.0.2
compatible ZIP file:
jar cvfO myArchive.zip *.class
To use a ZIP archive, simply use the HTML ARCHIVE tag
<APPLET CODE="a.class" ARCHIVE="abc.zip" WIDTH=618 HEIGHT=410> </APPLET>
[CAB format]
CAB (for CABINET) is used only by Microsoft Internet Explorer.
It offers compression (like the JAR but the ZIP format is un-compressed).
To create a CAB file, use the CABARC utility from Microsoft :
CABARC n myArchive.cab *.*
It is possible sign a CAB file using the Authenticode mechanism, check the Microsoft Web site for more infos.
To associate a CAB file with an Applet, simply use the HTML :
<APPLET CODE="a.class" WIDTH=100 HEIGHT=100> <PARAM NAME="cabbase" VALUE="abc.cab"> </APPLET>
An Applet can support ZIP and CAB format by using the following HTML:
<APPLET CODEBASE="." ARCHIVE=abc.zip CODE=a.class width=610 height=600 > <PARAM NAME="cabbase" VALUE="abc.cab"> </APPLET>