# Java: jar (Java Archive) Files

### How to set the program that starts with .jar files

    "C:\Program Files\Java\j2re1.4.2_04\bin\javaw.exe" -jar "%1" %*

## Misc jar manipulations

Here's the output from running jar with no parameters.

    Usage: jar {ctxu}[vfm0Mi] [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':
           jar cvfm classes.jar mymanifest -C foo/ .

To create a jar file

      jar cf jar-file-target input-file(s)

  It's not clear to me when the -C option should be used. I jarred the contents of the cards directory containing data with this.

      jar cd cards.jar cards

To list the contents of a jar file

      jar tf jar-file

To extract all files in a jar to the current directory

      jar xf jar-file

To add info to the manifest

      jar umf file-containing-manifest-info jarfile

## Making a .exe file

Site that has information on these issues
  URL: www.geocities.com/marcoschmidt.geo/java-native-compilers.html
JSmooth
  Open source. URL: jsmooth.sourceforge.net.
launch4j
  Open source. URL: launch4j.sourceforge.net/
Java Launcher
  Free to most. URL: http://www.syncedit.com/download_javalauncher.html
Jet
  Compiles Java to object code! Personal edition free. URL: http://www.excelsior-usa.com/home.html
NativeJ
  URL: www.dobysoft.com/products/nativej, $40 / $80, free trial.

## Installers

IzPack
  Free, open-source installer.
  URL: www.javalobby.com/articles/izpack/ - Good JavaLobby intro article by author of IzPack.
  URL: www.izforge.com/izpack - IzPack home page.