Java Reference
In-Depth Information
The jar tool automatically recurses into subdirectories. A “manifest file
describes the contents. Its inclusion is the only major difference between a JAR
and a standard ZIP file. (Below we discuss the manifest file with regard to running
applications directly from a JAR file.)
The jar tool can create a JAR file, display the contents of an existing JAR file,
and extract files from within a JAR file. As with some other SDK tools, running
jar without an argument results in a display of the options:
> jar
Usage: jar { ctxu
}
[vfm0M] [jar-file] [manifest-file] [-C dir]
files. . .
Options:
-c create new archive
-t list table of contents for archive
-x extract named (or all) files from archive
-u update existing archive
-v generate verbose output on standard output
-f specify archive file name
-m include manifest information from specified manifest file
-0 store only; use no ZIP compression
-M do not create a manifest file for the entries
-i generate index information for the specified jar files
-C change to the specified directory and include the
following file
If any file is a directory then it is processed recursively.
The manifest file name and the archive file name needs to
be specified in the same order the ' m ' and ' f ' flags are
specified.
Example 1: to archive two class files into an archive called
classes.jar: jar cvf classes.jar Foo.class Bar.class
Example 2: use an existing manifest file ' mymanifest '
and archive all the files in the foo/ directory into
' classes.jar ' :jarcvfm classes.jar mymanifest -C foo/.
Below we show how the jar tool displays the files in the TestABCApplet.
jar :
C: \ Java \ myApps> jar -tvf TestABCApplet.jar
0SatJun1216:59:48 EDT 2004 META-INF/
71 Sat Jun 12 16:59:48 EDT 2004 META-INF/MANIFEST.MF
1109 Sat Jun 12 16:52:08 EDT 2004 TestABCApplet.class
0SatJun1216:50:04 EDT 2004 mypack/
0TueNov1819:50:56 EST 2003 mypack/extrapack/
250 Sat Jun 12 16:51:48 EDT 2004 mypack/extrapack/TestC.class
129 Sat Jun 12 16:51:04 EDT 2004 mypack/extrapack/TestC.java
Search WWH ::




Custom Search