Java Tools Tutorials - Herong's Tutorial Notes - Version 5.32, by Dr. Herong Yang
Managing JAR Files with WinZIP
This section provides a tutorial example on how to manage a JAR file as a ZIP file with the ZIP tool, WinZIP.
The JAR specification says that "JAR file is a file format based on the popular ZIP file format". So are JAR files really ZIP files? Let's do some tests to find out.
Test 1. Create a JAR file, test.jar, with "jar" command. Rename test.jar to test.zip. Unzip test.zip with WinZIP. You should have no problem to extract all files out of test.zip with WinZIP.
Test 2. Create a ZIP file, tutu.zip, with WinZIP. Rename tutu.zip to tutu.jar. Extract files from tutu.jar with "jar". You should have no problem to extract all files out of tutu.jar with "jar" command.
Test 3. Create a password protected ZIP file, secure.zip, with WinZIP. Rename secure.zip to secure.jar. Extract files from secure.jar with "jar". You should get a run time exception like this:
C:\herong>jar tf secure.jar java.io.FileNotFoundException: secure.jar (The system cannot find the file specified) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:106) at java.io.FileInputStream.<init>(FileInputStream.java:66) at sun.tools.jar.Main.run(Main.java:185) at sun.tools.jar.Main.main(Main.java:904)
So JAR files and ZIP files are fully compatible, as long as no encryptions are used on ZIP files.
I guess I don't need WinZIP anymore.
Last update: 2015.
Table of Contents