How to use jar

jar is a file-collection program, like tar and zip: It collects together all the contents of a directory into one single file.

jar comes with javac, java, and javadoc in the Java Development Kit. It is available on all the KSU computers---if you can use javac on your computer, then you can use jar.

Say that you have a directory, Direc, that you want to collect together with jar. Do the following:

  1. Close Direc, that is, cd ..
  2. At the command line, type
    jar c Direc  > Direc.jar
    
    This tells jar to collect the contents of Direc into the newly created file, Direc.jar. The file will be created in the same directory where Direc lives.

If you wish to open Direc.jar, do this:

jar xvf Direc.jar
This will recreate directory Direc and its contents.