Thornton Rose
Published as "Using the Jar Manifest", 3/1/99, Gamelan.com.
Copyright © 2001, Thornton Rose.
After reading my articles on accessing zip and jar files using Java (Accessing Zips and Jars Using Java, Part 1 and Accessing Zips and Jars Using Java, Part 2), a friend and fellow programmer suggested I write about the jar manifest, because documentation on it was sparse at best. So in this article, I'll explain the purpose of the jar manifest and describe its format.
Name
is the name of the header and can be composed of letters,
numbers, "-", and "_", starting with a letter or number. Value
is
the value of the header and can be text or binary data, which must be encoded
as BASE64. Binary data is assumed for digests and
signatures.
Header lines can be can be terminated with carriage return (CR), linefeed (LF), or carriage return + linefeed (CRLF), and cannot exceed 72 characters in length, including the terminator. A header can be continued over multiple lines, though, by putting a space at the beginning of each subsequent line, like this:
At minimum, a manifest must contain one header, the Manifest-Version
header, and looks like this:
All other manifest headers are optional. Here is an example with more headers:
Manifest-Version: {version}
(required) -- This header is used to specify the version of the manifest format that this manifest is using.
Required-Version: {version}
-- This header is used to specify the minimum version of the manifest format that is required for the manifest.
Main-Class: {class}
-- This header is used to specify the main class of the application that is bundled in the jar file. Note the specified class must be listed later in the manifest.
Class-Path: {URL list}
-- This header is used to specify additional jar files that are needed for the application. The value is a list of URLs to jar files, separated by spaces. The URLs are specified relative to the URL of the jar file.
Here is an example of the preliminary headers:
Name: {class file}
(required) -- This header is used to specify the name and path of a class file.
Digest-Algorithms: {list}
-- This header is used to specify the algorithms that were used to produce digest values for the named class. This header is added when the jar file is signed.
{x}-Digest: {digest}
-- This header is used to specify a specific digest value for the named class. The digest value is the encoded representation of the class file at the time of signing. One of these headers is added for each algorithm specified in the Digest-Algorithms
header when the jar file is signed.
Java-Bean: True
-- This header is used to indicate that the named class is a JavaBean.
Here is an example of the class headers:
Name: {package path}/
(required) -- This header is used to specify the name and path of the package. Note that it must end in "/", which differentiates it from a class header.
Sealed: True
-- This header is used to indicate that the package is sealed, which means that all of the classes in the package must be contained in the jar file.
Specification-Title: {title}
-- This header is used to specify the title of the named package.
Specification-Version: {version}
-- This header is used to specify the version of the named package.
Specification-Vendor: {vendor}
-- This header is used to specify the vendor of the named package.
Implementation-Title: {title}
-- This header is used to specify the implementation-level title of the named package.
Implementation-Version: {version}
-- This header is used to specify the implementation-level version of the named package.
Implementation-Vendor: {vendor}
-- This header is used to specify the vendor of the implementation of the named package.
Here is an example of the package headers: