Recipe 23.5 Running an Applet from a JAR


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


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" ...>.


Once you've deployed the JAR file on the web server in place of the class file, you 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 the sidebar in Recipe 23.13.

Java Cookbook
Java Cookbook, Second Edition
ISBN: 0596007019
EAN: 2147483647
Year: 2003
Pages: 409
Authors: Ian F Darwin

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: