Java Reference
In-Depth Information
jar -cf ajarfile *.class
This command copies all the classes in the current directory to the jar file
named ajarfile . If any subdirectories exist in the current directory, that directory
is processed recursively (that is, any class files in a subdirectory are included in the
jar file, along with the subdirectory name). In addition, a manifest is created and in-
cluded in the jar file. It describes the contents of the jar file.
The following command updates an existing jar file with all the class files in the
current directory:
jar -uf ajarfile *.class
The next command lists the contents of the jar file ajarfile :
jar -tf ajarfile
or with more details:
jar-tvf ajarfile
After you've created a jar file, you can use it by treating it like a subdirectory in
your CLASSPATH directory. The CLASSPATH variable lists directories from
which any of these three class container types may exit:
The directory location of actual class files.
The initial directory for a package (that is, further subdirectories that may con-
tain class files).
The directory location where a jar file exists (which contains class files, perhaps
in subdirectories inside the jar file).
For example, the classes in a jar file named ajarfile.jar can be included in the
CLASSPATH option when running a Java program, as follows:
java -cp c:\java4cobolm,c:\java4cobol\ajarfile HelloWorld
In the case of an applet, a jar file is identified with the archive= parameter of the
applet tag, as follows:
Search WWH ::




Custom Search