JAR files

JAR files are a new feature in JDK 1.1. A JAR file is a convenient way of packaging together a set of class files and any associated GIF images, data files, or other resource files.

A JAR file consists of a normal ZIP format file, plus an optional manifest file describing the JAR contents.

You can use the JDK 1.1 jar command to create and read JAR files.

Manifest file

Each JAR file may contest a manifest file describing the contents of the JAR file. The manifest file must be named META-INF/MANIFEST.MF.

For the BDK 1.0, the JAR files containing beans should contain a META-INF/MANIFEST.MF manifest file giving the name of each bean class and specifying that it is a bean. So for example, the manifest file for the juggler.jar is initialized as:

        Name: sunw/demo/juggler/Juggler.class
        Java-Bean: True

See the manifest file specification for more information on manifest files.

The jar command

The jar command is provided as part of JDK 1.1. It allows you to either create a JAR file or to extract the content of a jar file.

The jar command syntax is:

    jar [ctxvfm] [jar-file] [manifest-file] files ...
    Option flags are:
        c  create new archive
        t  list table of contents for archive
        x  extract named (or all) files from archive
        v  generate verbose output on standard error
        f  specify JAR file name
        m  include manifest information from specified manifest file
    If any file is a directory then it is processed recursively.

So for example, the command "jar xf foo.jar" would extract all the files from the foo.jar JAR file and put them in the current directory.

The command "jar cfm fred.jar manifest.tmp *.class" would create a new JAR file called fred.jar, containing the given set of .class files, and with a manifest file initialized from manifest.tmp.


Java, JavaBeans, and JavaSoft are trademarks of Sun Microsystems Inc.

Copyright © 1996 Sun Microsystems, Inc., 2550 Garcia Ave., Mtn. View, CA 94043-1100 USA.
All rights reserved.