[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.
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:
In theory, you can specify many JARs in one ARCHIVE tag. But the current version of
Netscape will only load the first JAR and ignore the others.
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 |
According to some JAVA developers, JAR in CLASSPATH needs to be uncompressed (JDK1.1).
To create uncompressed JAR:
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 |
or check for InfoZIP at
http://www.cdrom.com/pub/infozip/
To use a ZIP archive, simply use the HTML ARCHIVE tag
[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 *.* |
to create 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 :
the cabbase parameter will be interpreted only by MSIE,
non-MS browsers browser will simply ignore it.
An Applet can support ZIP and CAB format by using the following HTML:
while Netscape will use the ZIP file and ignore de CAB parameter,
MSIE will use CAB and ignore the ZIP file.