The jar Tool

Sun's JDK contains a simple command-line program called jar that packages a set of files or a directory structure into a JAR file. Its syntax is modeled after the Unix tar command. For instance, to verbosely compress the directory com into the file javaio.jar with the manifest file javaio.mf, you would type the following command line:

This creates a file named javaio.jar. To extract files, change cvmf (c reate v erbose with m anifest f ile) to xvf (ex tract v erbose f ile). If you don't care to see each file as it's added or extracted, you can omit the v argument:

% jar xf javaio.jar

You can also use any other zip tool to create or unpack JAR archives. However, you'll have to include the META-INF/MANIFEST.MF file manually.

The JDK also includes a jarsigner tool that digitally signs JAR archives and verifies JAR archives signed by others using a public key system.