jar
User Commands jar(1)NAME
jar - Java archive toolSYNOPSIS
jar [ c ] [ f ] [ M ] [ m ] [ o ] [ t ] [ v ] [ x file ] [ manifest-file ] destination input-file [ input-files ]DESCRIPTION
The jar tool is a Java application that combines multiple files into a single JAR archive file. It is also a general-purpose archiving and compression tool, based on ZIP and the ZLIB compression format. However, jar was designed mainly to facilitate the packaging of Java applets or appli- cations into a single archive. When the components of an applet or application (.class files, images and sounds) are combined into a single archive, they may be downloaded by a Java agent (like a browser) in a single HTTP transaction, rather than require a new connection for each piece. This dramatically improves download time. The jar tool also compresses files and so further improves download time. In addition, it allows individual entries in a file to be signed by the applet author so that their origin can be authenticated. The syntax for the jar tool is almost identi- cal to the syntax for the tar(1) command. The three types of input files for the jar tool are: + manifest file (optional) + destination jar file + files to be archived Typical usage is: example% jar cf myjarfile *.class In this example, all the class files in the current direc- tory are placed in the file named "myjarfile". A manifest file is automatically generated by the jar tool and is always the first entry in the jar file. By default, it is named META-INF/MANIFEST.INF. The manifest file is the place where any meta-information about the archive is stored. Refer to the Manifest Format in the SEE ALSO section for details about how meta-information is stored in the manifest file. To use a pre-existing manifest file to create a new jar archive, specify the old manifest file with the m option: SunOS 5.8 Last change: 21 May 1997 1 User Commands jar(1) example% jar cmf myManifestFile myJarFile *.class When files are added to a jar archive, the file and its MD5 and SHA hashes are stored. The hashes are entered to the manifest file. It is easy to view and process the contents of the manifest file, since it uses RFC822 ASCII format.OPTIONS
The following options are supported: c Creates a new or empty archive on the stan- dard output. f The second argument specifies a jar file to process. In the case of creation, this refers to the name of the jar file to be created (instead of on stdout). For table or xtract, the second argument identifies the jar file to be listed or extracted. M Do not create a manifest file for the entries. m Includes manifest information from specified pre-existing manifest file. Example use: example% jar cmf myManifestFile myJarFile *.class You can add special-purpose name-value attri- bute headers to the manifest file that aren't contained in the default manifest. Examples of such headers would be those for vendor information, version information, package sealing, and headers to make JAR-bundled applications executable. See the JAR Files trail in the Java Tutorial and the JRE Notes for Developers web page for examples of using the m option. o Store only, without using ZIP compression. t Lists the table of contents from standard output. v Generates verbose output on stderr. x file Extracts all files, or just the named files, from standard input. If file is omitted, then all files are extracted; otherwise, only the specified file or files are extracted. SunOS 5.8 Last change: 21 May 1997 2 User Commands jar(1) If any of files is a directory, then that directory is pro- cessed recursively. EXAMPLES To add all of the files in a particular directory to an archive: example% ls 0.au 3.au 6.au 9.au at_work.gif 1.au 4.au 7.au Animator.class monkey.jpg e.au 5.au 8.au Wave.class spacemusic.au example% jar cvf bundle.jar * adding: 0.au adding: 1.au adding: 2.au adding: 3.au adding: 4.au adding: 5.au adding: 6.au adding: 7.au adding: 8.au adding: 9.au adding: Animator.class adding: Wave.class adding: at_work.gif adding: monkey.jpg adding: spacemusic.au example% If subdirectories for images, audio files, and classes already exist in an HTML directory, use jar to archive each directory to a single jar file: example% ls audio classes images example% jar cvf bundle.jar audio classes images adding: audio/1.au adding: audio/2.au adding: audio/3.au adding: audio/spacemusic.au adding: classes/Animator.class adding: classes/Wave.class adding: images/monkey.jpg adding: images/at_work.gif example% ls -l total 142 drwxr-xr-x 2 brown green 512 Aug 1 22:33 audio -rw-r--r-- 1 brown green 68677 Aug 1 22:36 bundle.jar drwxr-xr-x 2 brown green 512 Aug 1 22:26 classes drwxr-xr-x 2 brown green 512 Aug 1 22:25 images example% SunOS 5.8 Last change: 21 May 1997 3 User Commands jar(1) To see the entry names in the jar file using the jar tool and the t option: example% ls audio bundle.jar classes images example% jar tf bundle.jar META-INF/MANIFEST.MF audio/1.au audio/2.au audio/3.au audio/spacemusic.au classes/Animator.class classes/Wave.class images/monkey.jpg images/at_work.gif example% To display more information about the files, in the archive, such as their size and last modified date, use the v option. example% jar tvf bundle.jar 145 Thu Aug 01 22:27:00 PDT 1996 META-INF/MANIFEST.MF 946 Thu Aug 01 22:24:22 PDT 1996 audio/1.au 1039 Thu Aug 01 22:24:22 PDT 1996 audio/2.au 993 Thu Aug 01 22:24:22 PDT 1996 audio/3.au 48072 Thu Aug 01 22:24:23 PDT 1996 audio/spacemusic.au 16711 Thu Aug 01 22:25:50 PDT 1996 classes/Animator.class 3368 Thu Aug 01 22:26:02 PDT 1996 classes/Wave.class 12809 Thu Aug 01 22:24:48 PDT 1996 images/monkey.jpg 527 Thu Aug 01 22:25:20 PDT 1996 images/at_work.gif example%ATTRIBUTES
See attributes(5) for a description of the following attri- butes: __________________________________ | ATTRIBUTE TYPE| ATTRIBUTE VALUE| |_______________|_________________| | Availability | SUNWjvrt | |_______________|_________________|SEE ALSO
JAR Files @ http://java.sun.com/docs/books/tutorial/jar/ JAR Guide @ http://java.sun.com/products/jdk/1.1/docs/guide/jar/jarGuide.html Manifest Format @ http://sun.com/products/jdk/1.1/docs/guide/jar/manifest.html SunOS 5.8 Last change: 21 May 1997 4 User Commands jar(1) For information on related topics, use the search link @ http://java.sun.com/ SunOS 5.8 Last change: 21 May 1997 5