O'Reilly logo

Java Cookbook by Ian F. Darwin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Running an Applet from a JAR

Problem

You want to optimize downloading time for an applet by putting all the class files into one JAR file.

Solution

jar the applet and supporting files. Deploy the JAR file in place of the class file on the web server. Use <APPLET CODE="MyClass" ARCHIVE="MyAppletJar.jar" ...>.

Discussion

Once you’ve deployed the JAR file on the web server in place of the class file, you only need to refer to it in the APPLET tag in the HTML. The syntax for doing this is to use an ARCHIVE="name of jar file" attribute on the APPLET tag.

See Also

You can also store other resources such as GIF images for use by the applet. You then need to use getResource( ) instead of trying to open the file directly; see Step 5 in Section 23.12.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required