Building a Zip Archive
The first archive you will want to build is the ZIP archive, the oldest and most supported of the three. For this reason, it should be easy for you to find a ZIP archive generation program for whichever platform you are using. When choosing a ZIP utility program, however, you should be careful to choose one that supports non-8.3 filenames, since Java class files usually have names which are longer.
I recommend the popular WinZip , which is available for easy download at https://www.winzip.com/win/en/downwz.html. Regardless, every ZIP utility should have a similar interface and options, so if you are not using a Windows box, you can still get the basic idea from the following discussion.
The first step in creating a ZIP archive is to gather all of the class and supporting files necessary to execute your applet into the package structure defined in your Java code. This should be fairly simple, since you need to create a directory structure mirroring your package structure on your local machine in order to compile your Java files.
Once you have prepared your Java files to be archived, you should drag the top-level directory into WinZip.
You can also use your right mouse button to click on the MyApplet directory in Windows Explorer and choose “Add to Zip” from the popup menu.
When you submit the top-level directory to WinZip, the “Drag and Drop Dialog” should appear and give you several options for archiving. For the most part, the archiving options should be fairly straightforward, but we will present a laundry list for your convenience here. The options should be set as follows:
Select a name for your ZIP archive using the “Add to Archive” Text Field. Set the level of compression to “none” using the “Compression” Drop Down. Instruct WinZip to archive all files and all files within directories by toggling the “Recursive Folders” check box in the “Folders” Group.
Once you have set the options, hit the “Add” button and let WinZip do its magic. In a few moments, WinZip will finish archiving your applet. Make sure it recursively adds the directory structure.
However, you are not quite done yet. Actually, there are several files in the archive that do not need to be there, including all the .html, .java, and .txt files. After all, the web browser only needs the class files and images to execute. Thus, the final step in preparing the ZIP archive is to delete all of the extraneous files using the “Actions | Delete” choice from WinZip’s menu.
When you have deleted extraneous files, you can then upload your ZIP archive to your web server and make it available to web browsers using the ARCHIVE attribute, as in the following example:
<APPLET CODE = "MyApplet.class"
ARCHIVE = "MyApplet.zip"
WIDTH = "140" HEIGHT = "140">
Notice that you must still reference the base class in the CODE attribute even though it is contained in the ZIP file. After all, the web browser must still know where to begin. More importantly, browsers that cannot read ZIP files must still have access to the value of CODE.