Packaging Your Applet

After you have written your applet, you’ll want to combine its class files with those from the appropriate Oracle classesXXX.zip file into a single zip or jar file as you did for Example 3-1. This step is necessary because an applet using JDBC is naturally quite complex and contains many classes. Getting to just one file makes things easier to manage. It is also simpler and more efficient to specify just one file in the HTML APPLET tag rather than specify multiple archive files.

Tip

For simplicity’s sake, this discussion on packaging focuses on the use of JDK 1.2. If you are using JDK 1.1, the syntax for using the jar tool to create the jar file will be slightly different. If you use WinZip, the procedure will be the same as it is for JDK 1.2.

A Development Packaging Cycle

During the development stage for an applet, you can begin your packaging effort by simply making a copy of the Oracle classes12.zip file. Give it the name of your archive file but retain the .zip extension. Then add your applet’s class files, uncompressed, to the zip file that you just copied and renamed. Why uncompressed? I actually don’t know. This is an Oracle recommendation. I have used them as compressed class files when I have created a jar file, but I have never done so using a zip file. For example, if you’re going to create a zip file for an applet named TestAppletPolicy, you should follow these steps:

  1. Copy the file classes12.zip to TestAppletPolicy.zip. On a Windows system, you can ...

Get Java Programming with Oracle JDBC 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.