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

'jar' - JAR File Tool Command and Options

This section describes the 'jar' command to manage JAR files. 'jar' command syntax and options are provided.

"jar": A command line tool for managing JAR files. "jar" is distributed as part of the Sun JDK package. It has some interesting features:

  • It can create, update or extract a JAR file.
  • ZIP compression is optional.

"jar" command syntax:

Create jar file 
jar c[v0M]f jarfile inputfiles 
jar c[v0]mf manifest jarfile inputfiles

Update jar file 
jar u[v0M]f jarfile inputfiles
jar u[v0]mf manifest jarfile inputfiles

Extract jar file 
jar x[v]f jarfile [inputfiles]

List table of contents of jar file 
jar t[v]f jarfile [inputfiles]

where:

  • "c" - Creates a new JAR file.
  • "v" - Generates verbose output to standard output.
  • "0" - Specifies no compression.
  • "M" - Specifies no manifest file.
  • "f" - Specifies the JAR file name.
  • "m" - Specifies the manifest file name.
  • "u" - Updates a JAR file.
  • "x" - Extracts files out of a JAR file.
  • "t" - Displays the table of contents of a JAR file.

"jar" command is supported by the file, \j2sdk1.5.0\bin\jar.exe, if you installed JDK as in my previous chapter.

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' - JAR File Tool Command and Options