Attribute for <APPLET ...>
ARCHIVE = "URL"
Usage Recommendation |
use it |
ARCHIVE
designates the URL of a JAR (Java ARchive)
file. A JAR file is a compressed file containing the component files needed to run
an applet. For example, the applet below uses ten different class files. Using
just the CODE
attribute we can point to the top class, which will
load the others. That requires ten separate full file downloads. However,
ARCHIVE
indicates that "FieldTestF.jar" contains some (or all) of the needed
resources. The browser downloads the jar file first, and looks in the jar file
for class files it needs before heading back out on the net. This saves bandwidth
several different ways. Jar files are compressed and download quicker (in our
example our one jar file is 10K compared to 15K of class files). Downloading just
one file saves the overhead that would be required for (in this case) ten separate
downloads. Finally, if every class must be downloaded separately, the applet will
start and run as it can, but then stop when it has to wait for some component to
download. With jar files, everything is downloaded first, and the applet "starts
all at once", which is much more aesthetic.
<APPLET
CODE="FieldTestF.class"
WIDTH="100%" HEIGHT="90"
ARCHIVE = "FieldTestF.jar"
>
This example uses an applet.
</APPLET>
gives us this applet
Any kind of file can be put in a jar file, not just classes. Many people add images that will be used in the applet. Adding images, however, requires a little extra Java programming. For that and other technical details on creating Java applets, we refer you to the
applet
section of the
Java FAQ.