Technical Q&A

Java 04 - Using .zip and .jar Files With Applets (22-February-1999)


Q: Normally, when you run an applet, you have several class files, and an html file that calls your main class like this:



<APPLET CODE="MyMainClass.class" WIDTH=200 HEIGHT=200>< /APPLET>

What if I want to have all my classes in a .jar or .zip file? If this is possible, what html code do I now use to call the applet?

A: To load your applet classes from a .jar or .zip file, you need to use the " ARCHIVE" tag in your applet statement. An example of this would be:

<APPLET ARCHIVE="classes.jar" CODE="MyMainClass.class" WIDTH=200 HEIGHT=200>< /APPLET>

where "classes.jar" would be the name of your .jar or .zip file containing the "MyMainClass.class" and its supporting class files.


-- Levi Brown
Worldwide Developer Technical Support


Technical Q&As | Contents
Previous Question | Next Question

To contact us, please use the Contact Us page.