Java Tool Tutorials - Herong's Tutorial Notes
Dr. Herong Yang, Version 5.00

JAR - Java Archive File Format

This section describes the Java archive, JAR, file format, which is an extension of the ZIP file format.

JAR (Java Archive): A file format that compresses many files into a single package file. A JAR may contain additional package attributes and supporting data. It has some interesting features:

  • It uses the standard ZIP algorithm for compression.
  • Package attributes and supporting data are stored as files in a special directory called META-INF.

The main purpose of a JAR file is to aggregate your .class files, not your .java files, into a single file to distribute them to your customers. A JAR file can be directly included in the class path if you want to access those class files in the JAR file. No need to extract those class files into Java class directories.

Usually, JAR files are managed by the 'jar' tool provided in the JDK package.

But JAR files can also be managed by most ZIP tools, since JAR files are really ZIP files.

Sections in This Chapter

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

Dr. Herong Yang, updated in 2008
JAR - Java Archive File Format