Tool for creating archive files, shipped with JDK.

Usage syntax:

jar c|t|x[f][m][v] [jarfile] [manifestfile] files...

Options:

First letter is for create/list/extract, just like in tar program. from is used to say you want to read/write from/to a file jarfile (if not specified, it will read/write from/to standard input/output. m option is used with creation option to add stuff in manifestfile to the archive's MANIFEST. v just increases verbosity. All in all, very much like tar's syntax.

There are other options too, but they're less needed. Just type "jar" to get a summary.

Example:
jar cvf myproggie.jar *.class
jar cvmf myproggie.jar moneyfest.stub *.class

The JAR archives are normal zip archive files, but they typically contain a file called META-INF/MANIFEST that lists the files and other wacky parameters.

Handy Tip: In Java2 (JDK 1.2 and later), it's possible to add a parameter "Main-Class" to the manifest file to tell which class has the main() method. Like this:

$ echo "Main-Class: Frobnicator" > mainclass.stub
$ jar cvfm frobnicator.jar mainclass.stub *.class

This makes distributing and using the program much easier because you can say stuff like this to start the program:

$ java -jar frobnicator.jar