Introduction

There are two kinds of sections in a manifest file: the main section and the individual section.

Entries in the main section apply to the entire JAR file.

Entries in the individual section apply to a particular entry.

An attribute in an individual section overrides the same attribute in the main section.

An individual entry starts with a "Name" attribute, whose value is the name of the entry in the JAR file and it is followed by other attributes for that entry.

For example, suppose you have a manifest file with the following contents:

Manifest-Version: 1.0
Created-By: 1.6.0 (Sun Microsystems Inc.)
Main-Class: com.book2s.chapter2.Welcome
Sealed: true

Name: book/data/
Sealed: false

Name: images/logo.bmp
Content-Type: image/bmp

The manifest file contains three sections: one main section and two individual sections.

A blank line is between the two sections.

The first individual section indicates that the package book/data is not sealed.

This individual section attribute of "Sealed: false" will override the main section's attribute of "Sealed: true".

Another individual section is for an entry called images/logo.bmp. It states that the content type of the entry is an image of bmp type.

Default Section

The jar command can create a default manifest file and add it to the JAR file.

The default manifest file contains only two attributes: Manifest-Version and Created-By.

You can use the option M to tell the jar tool to omit the default manifest file.

The following command will create a test.jar file without adding a default manifest file:

jar cMf test.jar book/*.class

Related Topic