JAR Files
Java 1.1 added support for Java ARchive
files, JAR files for short. JAR files bundle the many different
classes, images, and sound files an applet requires into a single
file. It is generally faster for a web browser to download one JAR
file than to download the individual files the archive contains,
since only one HTTP connection is required. An applet stored in a JAR
file, instead of as merely loose .class files,
is embedded in a web page with an <applet>
tag with an archive attribute pointing to the JAR
file. For example:
<applet code=NavigationMenu archive="NavigationMenu.jar" width=400 height=80> </applet>
The code attribute still says that the main class
of this applet is called NavigationMenu. However,
a Java 1.1 web browser, rather than asking the web server for the
file NavigationMenu.class as a Java 1.0 web
browser would, asks the web server for the file
NavigationMenu.jar. Then the browser looks
inside NavigationMenu.jar to find the file
NavigationMenu.class. Only if it doesn’t
find NavigationMenu.class inside
NavigationMenu.jar does it then go back to the
web server and ask for NavigationMenu.class. Now
suppose the NavigationMenu applet tries to load an
image called menu.gif. The applet will look for
this file inside the JAR archive too. It only has to make a new
connection to the web server if it can’t find
menu.gif in the archive.
Sun wisely decided not to attempt to define a new file format for JAR files. Instead, they stuck with the tried-and-true zip format. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access