Jar-The Java Archive Tool

zhaozj2021-02-17  45

Jar-The Java Archive Tool

Combines Multiple Files Into a Single Jar Archive File.

Synopsis

Jar [options] [manifest] destination input-file [input-files]

Description

THE

Jar Tool Is a Java Application That Combines Multiple Files Into A Single Jar Archive File.

Jar is 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 applications 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), Rather Than Requiring a new connection for each point. this diamatically improves download time->

jar 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 identical to the syntax for the

Tar Command.

The 3 Types of Input Files for the Jar Tool Are

Manifest File (optional) Destination Jar File Files To Be Archived

Typical Usage IS

% jar cf myjarfile * .class

In this example, all the class files in the current directory are placed into 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 specification for details about how meta-information is stored in the manifest file.If you have a pre-existing manifest file that you want the jar tool to use for the new jar archive, you can specify it using the -m option:

% 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 into the manifest file. It is easy to view and process the contents of the manifest file, since it uses RFC822 ascii format.

Options

c

Creates a New or Empty Archive on The Standard Output.

t

Lists the Table of Contents from Standard Output.

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.

fly

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 create (instead of on stdout). for

Table OR

Xtract, The Second Argument Identifies The Jar File to Be Listed or Extracted.

v

Generates Verbose Output on stderr.

M

Includes Manifest Information from Specified Pre-EXISTING MANIFEST FILE. EXAMPLE USE:

JAR CMF mymanifestfile myjarfile * .class

You can add special-purpose name-value attribute headers to the manifest file that are not contained in the default manifest. Examples of such headers would be those for vendor information, version information, and package sealing. See the

Jar Files Trail in Java Tutorial for Examples of Using To

M Option.

0

Store ONLY, WITHOUT Using Zip Compression.

M

Do Not Create a Manifest File for the Entries.

IF any of

"Files" Is A Directory, THT Directory IS Processed Recursively.examples

To add all the files in a Particular Directory to an archive:

C: / wwwroot / java> ls

12/09/96 12: 20A

.

12/09/96 12: 17A

..

12/09/96 12: 18A 1,010 0.au

12/09/96 12: 18A 946 1.AU

12/09/96 12: 18A 1,039 2.au

12/09/96 12: 18A 993 3.au

12/09/96 12: 18A 1,006 4.au

12/09/96 12: 18A 1,016 5.au

12/09/96 12: 18A 1,048 6.au

12/09/96 12: 18A 980 7.au

12/09/96 12: 18A 1,064 8.au

12/09/96 12: 18A 989 9.au

12/09/96 12: 19A 48, 072 Spacemusic.au

12/09/96 12: 19A 527 AT_Work.gif

12/09/96 12: 19A 12,818 monkey.jpg

12/09/96 12: 19a 16,242 Animator.class

12/09/96 12: 20A 3, 368 Wave.class

17 File (s) 91,118 bytes

414, 983, 168 BYTES Free

C: / wwwroot / java> jar cvf bundle.jar *

Adding: 0.au

Adding: 1.au

Add: 2.au

Adding: 3.au

Adding: 4.au

Add: 5.au

Adding: 6.au

Add: 7.au

Adding: 8.au

Adding: 9.au

Add: animator.class

Adding: Wave.class

Adding: at_work.gif

Adding: monkey.jpg

Adding: Spacemusic.au

C: / wwwroot / java>

IF Already Have Subdirector For Images, Audio Files and Classes in My HTML Directory, I Might Jar Up Each Directory Into A Single Jar File:

C: / wwwroot / java> DIR

12/09/96 12: 11A

.

12/09/96 12: 17A

..

12/03/96 06: 54P

Audio

12/06/96 02: 02P

images

12/09/96 12: 10A

Classes6 File (s) 207,360 bytes

414, 983, 168 BYTES Free

C: / wwwroot / java> JAR CVF Bundle.jar Audio Classes Images

Adding: AUDIO / 1.AU

Adding: AUDIO / 2.AU

Adding: AUDIO / 3.AU

Adding: Audio / Spacemusic.au

Adding: class / animator.class

Add: Classes / Wave.class

Adding: Images / Monkey.jpg

Adding: images / at_work.gif

C: / wwwroot / java / annator> DIR

12/09/96 12: 11A

.

12/09/96 12: 17A

..

12/09/96 12: 11A 207, 360 bundle.tar

12/03/96 06: 54P

Audio

12/06/96 02: 02P

images

12/09/96 12: 10A

classes

6 File (s) 207, 360 bytes

414, 983, 168 BYTES Free

C: / wwwroot / java / annator>

I can death, the jar tool and the "t" option:

C: / wwwroot / java / annator> 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

C: / wwwroot / java / annator>

ENUMERATING VERBOSELY (with the "v" option) Will Tell Me More Information About The Files in The Archive, Such As Their Size and Last Modified Date:

C: / wwwroot / java / annator> 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.jpg527 thu aug 01 22:25:20 PDT 1996 images / at_work.gif

C: / wwwroot / java / annator>

转载请注明原文地址:https://www.9cbs.com/read-28627.html

New Post(0)