Java Beans   «Prev  Next»
Lesson 3JavaBeans Manifest File
ObjectiveHow JAR files containing Beans require a manifest file

JavaBeans Manifest File

Find out how JAR files containing Beans require a manifest file.
Each JAR file containing a Bean must have a manifest file, which is a text file containing information about the Bean.
This is necessary so that application builder tools can quickly analyze the manifest file and determine what Beans are in the JAR file.
Let us now examine a typical manifest file:

Manifest-Version: 1.0
Name: SomeBean.class
Java-Bean: True

Manifest-Version: 1.0 // line 1
// line 2
Name: SomeBean.class // line 3
Java-Bean: True // line 4

  1. The first line of the manifest file simply states the version of JAR utility used to create the archive.
  2. The second line is left blank.
  3. The third line lists the name of the Bean class, which in this case is SomeBean.class.
  4. The fourth line indicates that the class is in fact a Bean class. This is necessary because JAR files can also be used to package normal Java classes.
If a JAR file contains more than one Bean, the third and fourth lines of the manifest file will be repeated for each different Bean.

J2EE FrontEnd Technologies


The jar program automatically generates a manifest when the archive is created (unless you specify the M option). The manifest is always named and placed into a directory named METAINF, and is made up of one or more sections, each of which describes an entry in the archive. Sections in the manifest are separated by a blank line and each section in the manifest contains a series of attribute/value pairs. These pairs are used to specify various attributes of the contents of the archive. The entries in the manifest take the form
attribute: value, 

where the attribute is immediately followed by a colon and whitespace, and then the value. The first section in the archive is used to identify the manifest version used by the archive. The name of the attribute is Manifest-Version. The only version currently supported is 1.0, so the first section of the manifest looks like this: Manifest-Version: 1.0
The version section is followed by sections that describe the elements contained in the archive.Each section contains an attribute called Name that identifies the name of the archived element. The jar program also produces some hash values for the archived element and each of these values is entered into the manifest. The Digest-Algorithms attribute specifies one or more hash algorithms used to generate hash values for the element. This is followed by attributes for each of the algorithms, with the associated hash value.
In the next lesson, how to work with JAR files using the JAR utility will be discussed.