23.07.2013 Views

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

Java IO.pdf - Nguyen Dang Binh

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Java</strong> I/O<br />

example, under Unix, to make the classes in the JAR archive jce12-rc1-dom.jar in the<br />

directory /usr/local/java/lib available to your program, you'd use this command:<br />

% setenv CLASSPATH $CLASSPATH:/usr/local/java/lib/jce12-rc1-dom.jar<br />

The JAR file is treated like a directory in the context of the class path. This is sensible,<br />

because although the archive is a file to the file system, it behaves like a directory to <strong>Java</strong>.<br />

9.5.1 Meta-Infomation: Manifest Files and Signatures<br />

Aside from the three-letter extension, the only distinction between a zip file and a JAR file is<br />

that most (though not all) JAR files contain a manifest file that lists the contents of the JAR<br />

file as well as various information about those contents. The manifest file is named<br />

MANIFEST.MF and is stored in the META-INF directory at the top of the archive. This file<br />

provides meta-information about the contents of the archive in a particular format. This<br />

directory and file are not necessarily present in the unarchived collection. Generally, a<br />

manifest is added as part of the archiving process. The lefthand side of Figure 9.3 shows a<br />

directory structure for the com.macfaq package that can be stored in a JAR archive. The<br />

righthand side shows the contents of the corresponding JAR archive.<br />

Figure 9.3. JAR archive: before and after<br />

At a minimum, a manifest file must contain this opening line:<br />

Manifest-Version: 1.0<br />

A manifest usually contains additional entries for some of the files in the archive. However,<br />

the manifest does not necessarily contain an entry for every file in the archive. Entries are<br />

separated from each other by a blank line. Each entry is composed of a list of name/value<br />

177

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!