jar cf <jar-file> <input-files>
c - option indicates that you want to create a JAR file.
f - option indicates that you want the output to go to a file rather than to stdout.
jar-file - is the name that you want the resulting JAR file to have. You can use any filename for a JAR file. By convention, JAR filenames are given a .jar extension, though this is not required.
input-file(s) - is a space-separated list of one or more files that you want to be placed in your JAR file.
If any of the "input-files" are directories, the contents of those directories are added to the JAR archive recursively.
v - Produces verbose output on stderr (in version 1.1) or stdout (in version 1.2) while the JAR file is being built. The verbose output tells you the name of each file as it's added to the JAR file.
0(zero) - Indicates that you don't want the JAR file to be compressed.
M - Indicates that the default manifest file should not be produced.
C - To change directories during execution of the command. Version 1.2 only. See below for an example.
m - Used to include manifest information from an existing manifest file. The format for using this option is:
jar cmf <existing-manifes>t <jar-file> <input-files>
jar cvf <myjarName>.jar <input-Files or Directory>
Suppose you wanted put audio files and gif images demo into a JAR file, and that you wanted all the files to be on the top level, with no directory hierarchy.
You could accomplish that by issuing this command from the parent directory of the images and audio directories:
jar cf <jarFileName>.jar -C images . -C audio .The -C images part of this command directs the Jar tool to go to the images directory, and the . following -C images directs the Jar tool to archive all the contents of that directory. The -C audio . part of the command then does the same with the audio directory.
Author : Anuj Patel
Blog : http://goldenpackagebyanuj.blogspot.in/