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
tag with an
archive attribute pointing to the JAR
file. For example:
<applet code=NavigationMenu archive="NavigationMenu.jar" width=400 height=80> </applet>
code attribute still says that the main class
of this applet is called
a Java 1.1 web browser, rather than asking the web server for the
NavigationMenu.class as a Java 1.0 web
browser would, asks the web server for the file
NavigationMenu.jar. Then the browser looks
NavigationMenu.jar to find the file
NavigationMenu.class. Only if it doesn’t
NavigationMenu.jar does it then go back to the
web server and ask for
NavigationMenu applet tries to load an
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. ...
Get Java I/O now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.