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? I did 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:

herong> jar --list --file secure.jar
java.util.zip.ZipException: invalid CEN header (encrypted entry)
   at java.base/java.util.zip.ZipFile$Source.zerror(ZipFile.java:1527)
   at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1493)
   ...
   at jdk.jartool/sun.tools.jar.Main.list(Main.java:1488)
   at jdk.jartool/sun.tools.jar.Main.run(Main.java:373)
   at jdk.jartool/sun.tools.jar.Main.main(Main.java:1669)

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. I can use "jar" command to manage ZIP files.

Or I don't need "jar" command. I can use WinZIP to manage JAR files!

Table of Contents

 About This Book

 Java Tools Terminology

 Java Tools Included in JDK

 javac - The Java Program Compiler

 java - The Java Program Launcher

jar - The JAR File Tool

 JAR - Java Archive File Format

 jar - JAR File Tool Command and Options

 "jar --create" - Creating New JAR File

 "jar --list" - Listing Files in JAR File

 "jar --extract" - Extracting Files from JAR File

Managing JAR Files with WinZIP

 META-INF/MANIFEST.MF - JAR Manifest File

 Adding META-INF/MANIFEST.MF to JAR Files

 "jar -C" - Changing Input Directory

 Using JAR Files in Java Class Paths

 "jar --update" - Updating Class Files in JAR

 "jar --main-class" - Making JAR File Executable

 Creating Module JAR File

 "jar --module-version" - Updating Module Version in JAR

 jlink - The JRE Linker

 jmod - The JMOD File Tool

 jimage - The JIMAGE File Tool

 jpackage - Binary Package Builder

 javadoc - The Java Document Generator

 jdeps - The Java Class Dependency Analyzer

 jdeprscan - The Java Deprecated API Scanner

 jdb - The Java Debugger

 jcmd - The JVM Diagnostic Tool

 jconsole - Java Monitoring and Management Console

 jstat - JVM Statistics Monitoring Tool

 JVM Troubleshooting Tools

 jhsdb - The Java HotSpot Debugger

 jvisualvm (Java VisualVM) - JVM Visual Tool

 jmc - Java Mission Control

 javap - The Java Class File Disassembler

 keytool - Public Key Certificate Tool

 jarsigner - JAR File Signer

 jshell - Java Language Shell

 jrunscript - Script Code Shell

 Miscellaneous Tools

 native2ascii - Native-to-ASCII Encoding Converter

 JAB (Java Access Bridge) for Windows

 Archived Tutorials

 References

 Full Version in PDF/EPUB