Creating and Editing Manifest Entries

JClass JarMaster lets you create and edit manifest file entries for class files and packages with its Manifest Editor.

It is important to have a manifest file for your JAR that contains properly defined manifest entries. If you plan on using the JAR with an IDE, or if dynamic dependencies exist, these must be set in the Manifest Editor; otherwise, your JAR may not work when loaded by an application or IDE.

The JarMaster Wizard and Add Dependencies procedure help you put together an accurate manifest file. However, they can only do so if a manifest file already exists for the classes you are adding to the JAR. During these procedures, JarMaster cannot create a manifest file from scratch for you.

In this case, you must properly create and define it using the Manifest Viewer (to view entire manifest files) and the Manifest Editor (to edit/create individual manifest entries).

For more information about manifest files, please refer to Sun's Java Technology Home Page, and search for information about JAR manifests. Also, see the Manifest Format Specification that comes along with the J2SE documentation.

To edit manifest file entries:

  1. Open or select the JAR whose manifest file you want to modify or create.
  2. Click Tools, then Manifest Editor. The Manifest Editor dialog box appears. The manifest file consists of a Main section followed by zero or more Entry Sections (or individual sections).
  3. Edit the file either by editing the attributes in the Main Section, or by adding, removing, or editing the current Entry section attributes. Selecting a different Entry in the list selection box, or creating a new Entry, automatically saves any changes to the previous Entry. The Main attributes and the current Entry's attributes are saved when the Okay button is hit. Hitting the Exit button causes all changes to the Main attributes and current Entry to be discarded.
  4. Click File, then Save to update the manifest file with these new or changed entries.

Breakdown of Manifest Editor Dialog Box

There is a lot of information displayed in the Manifest Editor dialog box, and much of it depends on the type of manifest entry that has your current focus. The following is a description of the main elements of the dialog box:

A - This area contains package information for the JAR. It is part of the Main section attributes.

B - This area contains the mainClass attribute (part of the Main section). This attribute is used by stand-alone applications that are bundled into executable JAR files, which can be invoked by the java runtime directly by running java -jar x.jar. This should reference a class file that has a main method. However, it should not have a .class extension. The mainClass value can be typed in directly or selected from the JAR via a Main Class Editor using the ... button.

C - This area points to the Entry Name list selection box. Selecting an entry allows you to edit its properties. You can also add an entry by clicking on the Add button. This pops up a dialog which allows you to select a class file or a package name. The Remove button allows you to remove the current entry.

D - These check boxes act both as indicators and switches for class files (but not for packages). Clear or select these check boxes to indicate the status of the class file.

If the class is a Bean (meant to be directly used by an IDE), ensure the Bean check box is selected.

E - The File Dependency Attribute list allows you to verify and define dynamic dependencies. Dynamic dependencies appear as Strings in a program's code, but are converted to classes at run time. For example, imagine your Foo.java file contains this method:

Class.forName("com.klg.MySample")

Since the dynamically loaded MySample class is a String object, JarMaster will not pick it up when creating JARs and determining dependencies. To ensure it is included, it needs to be listed in the manifest file as a dynamic dependency for Foo.java:

Name: Foo.java
Depends-On:com/klg/MySample

This is accomplished by entering the class name in this dependency list. You only need to specify the path for the class; JarMaster adds the Depends-On tag for you.

Note: In the actual Manifest file there is only one "Depends-On" attribute per Entry section. Multiple dependencies are appended together (separated by spaces). Long lines are broken at 72 characters, and are continued on the next line. Continuation lines begin with a space.

F - You can edit versioning information for a section (packages only) by clicking the Edit Section Versioning Attributes... button. A dialog pops up which allows you to override the Main section versioning attributes for the particular Entry section.

G - Although the manifest editor handles the main types of entries, there are other standard attributes that JarMaster does not directly support. You can enter this type of manifest information by clicking on the Edit Other Attributes... button. This pops up a dialog which allows you to enter these attributes.

Note: Since there is no direct support for these attributes, you must enter complete manifest attributes here. The name-value pairs appear in the manifest file exactly as you type them here (other than the formatting that results from line splitting for lines that exceed 72 characters).