Using the AppletArchiver to create a .jar or .cab archive
- Contents
- What the AppletArchiver does
- How to create an archive with the AppletArchiver
- Examples
- Change history
What the AppletArchiver does
When you are serving applets from an HTTP server, you can increase the
speed at which your applet loads by archiving the classes and
resources needed by the applet into a .jar or .cab
file. WebLogic supplies a utility, called the AppletArchiver, to help
you create such a file.
The AppletArchiver utility loads and views applets in a separate
window, remembers all of the remote classes and resources loaded by
the applet, and when the window is closed, packages these classes in
either .jar or a .cab file format. This document explains how
to use the AppletArchiver utility to create an archive file, where to
store the archive on your WebLogic Server, and how to refer to the
archive in your applet's APPLET tag.
Not all browsers can use .jar/.cab-type archives. Here are the
browsers that are archived-enabled:
- Netscape browsers after version 3.0 -- .jar files only
- Microsoft IE browsers after version 4.0 -- .cab files only
You can create both types of archives for your applet and include both
filenames in the APPLET tag. Browsers that do not read either type of
file can load your applet classes individually, using the CODE and
CODEBASE that you have set.
Note that creating a .cab file
requires the presence of the Microsoft SDK (specifically the cabarc.exe tool). You can get this directly
from Microsoft. The jar archiver is distributed with the JDK.
How to create an archive with the AppletArchiver
- Load your applet on a webserver, like the WebLogic Server.
(There is more on how to do this in
Using WebLogic for applet programming.
- Unset your CLASSPATH in the environment in which you plan to run
the AppletArchiver. This is to ensure that the tool doesn't load
classes locally from your CLASSPATH; it forces the tool to load all
the classes it needs from the webserver.
You will be able to tell that your CLASSPATH is set incorrectly if the AppletArchiver creates
an archive file with a file size of zero bytes. There are two ways you can reset your CLASSPATH:
- Remove the class files for the applet from the local CLASSPATH.
- In the AppletArchiver Tool, under Options > Remote Class Loading, there is a list of
strings such as "weblogic," and "tutorial". If the class name in question begins with any of these
strings, the tool will obtain the class from the HTTP server, even if it also exists in the local CLASS PATH.
If you add your class name to this list, all classes beginning with that name will be forced to load remotely.
There is more information below.
- Start the AppletArchiver. Either run it from the command line with
this command:
$ java utils.applet.archiver.AppletArchiver
(There is a syntax and usage summary in Using the WebLogic utilities.)
Or, if you installed WebLogic with the .exe version (the InstallShield
version for Windows NT), find the Utilities folder in the WebLogic
WebLogic folder of the Start menu; the select the AppletArchiver from
the Utilities folder to run it.

Finding the Utilities folder from the Windows Start menu
- In the AppletArchiver window, enter the URL for
the applet.
- In the AppletArchiver window, enter the name for the
archive file you will create.
- Click a check box to select the type of archive you want to
create, either .jar or .cab file format. Note: The
option to create a file in .cab format
will only be displayed if you are running AppletArchiver on
Windows95/NT.
- Unclick the "Compress.jar" check box if you do not want to
compress the .jar file. For Netscape
Navigator 3.x the .jar files must be uncompressed; for Netscape
Navigator 4.x archive files may be compressed. Files in .cab format
are always compressed.
The AppletArchiver
- From the Options menu, select "Remote class-loading list."
Use this list to specify the package names of classes that, if your
applet uses, you want to force to be loaded from the applet host,
rather than from your local CLASSPATH. If your applet uses the same
packages that you have been developing with on your local machine,
selecting those package names will make sure that all of the
classes needed for your applet are loaded from the applet host, which
is necessary to create the full archive to support your applet. You
should also force remote loading for any classes that the browser
generally will not have locally (for example, all classes that aren't
java.* or sun.*).
You can force certain classes to be loaded remotely in the tool even
if they are in your local CLASSPATH. In the main window for the
Archiver, select the Remote class-loading list from the Options
menu. Any class that starts with a string on the list in the
resulting dialog box will be loaded from the codebase (the classes
must of course be on the HTTP server).
List of packages to force-load from the applet host
To add to this list, type a package name in the text box and clicking
"Add." To delete a package name, select the name from the list
and click "Delete." Click "OK" to accept the list of packages
and put away the window.
-
Click the "Get it" button to open and run your applet in a separate
window.
- Completely exercise all of the applet's features, so all of the
classes, images, audio clips, and other "resource" files are
downloaded and included in the archive file.
Note: The AppletArchiver's classloader will load and store the
classes for all of the applets with the same URL or codebase. If you
have more than one applet on an HTML page, you may accidentally create
an archive file for more than one applet.
- From the Options menu in the applet window, select Show
tag.
This will open another window displaying all of the attributes of the
applet. These attributes are taken from the APPLET tag on the HTML
page with which you loaded the applet. To close this window, click the
close-box in the upper left-hand corner.
AppletArchiver, with applet running
and Attributes window displayed
- To close the window and save your archive, select "Quit and Save"
from the Options menu. (Approximate file size will be indicated
in the AppletArchiver message area.)
- Place the .jar/.cab
archive in your webserver's document root or WebLogic's documentRoot. The archive
should be located in the directory that maps to the CODEBASE
you set in your APPLET tag.
- Edit the HTML file that loads your applet to add the ARCHIVE
attribute to the APPLET tag and copy it into your webserver's
document root or WebLogic's documentRoot. (IE browsers do not use the
standard ARCHIVE attribute, but rather set an applet PARAM tag,
as shown below.)
For example, this is how you might set up an applet called myapplet:
Add the following <APPLET>
tag to an HTML file (e.g. "myapplet.html") to include the applet:
<APPLET CODEBASE="/classes/"
CODE="examples.applets.myapplet"
ARCHIVE="foo.jar"
WIDTH=400
HEIGHT=400>
</applet>
If you need help setting the CODEBASE and CODE for your applet, check
the Tech Tip, Troubleshooting CODEBASE.
- Test your applet from a remote machine, or a shell where you have set the
system CLASSPATH to be empty. This
will guarantee that the browser or appletviewer will load the applet classes
via the server, and not the local machine. The URL we used to
access the applet described in the last step was:
http://WebLogicURL:WebLogicPort/classes/myapplet.html
where WebLogicURL and WebLogicPort are the WebLogic Server
host URL and the port at which WebLogic is listening for login requests.
Examples
Here is are some examples of APPLET tags that reference archives. For
Appletviewer, Netscape Navigator, or HotJava viewers, the APPLET tag
use the standard ARCHIVE attribute to reference an archive, as shown
here:
<APPLET CODEBASE="/classes/"
CODE="examples.applet.myapplet.html"
ARCHIVE="foo.jar"
WIDTH=400
HEIGHT=400>
</APPLET>
Internet Explorer uses an applet PARAM tag that
refers to the archive. For Internet Explorer, the APPLET tag uses the
pattern:
<APPLET CODEBASE="/classes/"
CODE="examples.applet.myapplet.html"
WIDTH=400
HEIGHT=400>
<PARAM NAME=cabbase VALUE="foo.cab">
</APPLET>
To ensure that your applet is compatible with all web browsers, you can
combine both types of archive syntax, and distribute your classfiles in a
non-archived format. For example:
<APPLET CODEBASE="/classes/"
CODE="examples.applet.myapplet.html"
ARCHIVE="foo.jar"
WIDTH=400
HEIGHT=400>
<PARAM NAME=cabbase VALUE="foo.cab">
</APPLET>
For more information, check these related topics:
Change history
- Release 3.1
-
Fixed a problem with the Applet Archiver tool that caused
it to miss some applet tags.

|