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

 About This Book

 Java Tools Terminology

 Installing Java 8 on Windows

 'javac' - The Java Program Compiler

 'java' - The Java Program Launcher

 'jdb' - The Java Debugger

 'jconsole' - Java Monitoring and Management Console

 'jstat' - JVM Statistics Monitoring Tool

 JVM Troubleshooting Tools

 jvisualvm (Java VisualVM) - JVM Visual Tool

'jar' - The JAR File Tool

 JAR - Java Archive File Format

 'jar' - JAR File Tool Command and Options

 Creating the First JAR File - hello.jar

Managing JAR Files with WinZIP

 META-INF/MANIFEST.MF - JAR Manifest File

 Adding META-INF/MANIFEST.MF to JAR Files

 Using JAR Files in Java Class Paths

 Creating Executable JAR Files

 'javap' - The Java Class File Disassembler

 'keytool' - Public Key Certificate Tool

 'native2ascii' - Native-to-ASCII Encoding Converter

 Outdated Tutorials

 References

 PDF Printing Version