Manifest file

Manifest file

On the Java platform, a Manifest file is a specific file contained within a JAR archive[1][2]. It is used to define extension and package-related data. It is a metadata file that contains name-value pairs organized in different sections. If a JAR file is intended to be used as an executable file, the manifest file specifies the main class of the application. The manifest file is named MANIFEST.MF.

It is not uncommon to find a computer file described as a manifest in situations unrelated to Java.

Contents

Specifications

A JAR file includes a manifest at the canonical location META-INF/MANIFEST.MF [3]. There can be only one manifest file in an archive, and it necessarily has to be in the META-INF directory.

The content of the Manifest file in a JAR file created with version 1.0 of the Java Development Kit is the following.

Manifest-Version: 1.0

All the entries are as name-value pairs. The name of a header is separated from its value by a colon. The default manifest shows that it conforms to version 1.0 of the manifest specification.

The manifest can also contain information about the other files that are packaged in the archive. Exactly what file information is recorded in the manifest will depend on the intended use for the JAR file. The default manifest file makes no assumptions about what information it should record about other files, so its single line contains data only about itself.

Special-Purpose Manifest Headers

Depending on the intended role of the JAR file, the default manifest may have to be modified. If the JAR file is created only for the purpose of archival, then the MANIFEST.MF file is of no purpose.

Most uses of JAR files go beyond simple archiving and compression and require special information to be in the manifest file. Summarized below are brief descriptions of the headers that are required for some special-purpose JAR-file functions

Applications Bundled as JAR Files: If an application is bundled in a JAR file, the Java Virtual Machine needs to be told what the entry point to the application is. An entry point is any class with a public static void main(String[] args) method. This information is provided in the Main-Class header, which has the general form:

Main-Class: classname

The value classname is to be replaced with the application's entry point.

Download Extensions: Download extensions are JAR files that are referenced by the manifest files of other JAR files. In a typical situation, an applet will be bundled in a JAR file whose manifest references a JAR file (or several JAR files) that will serve as an extension for the purposes of that applet. Extensions may reference each other in the same way.

Download extensions are specified in the Class-Path header field in the manifest file of an applet, application, or another extension. A Class-Path header might look like this, for example:

Class-Path: servlet.jar infobus.jar acme/beans.jar

With this header, the classes in the files servlet.jar, infobus.jar, and acme/beans.jar will serve as extensions for purposes of the applet or application. The URLs in the Class-Path header are given relative to the URL of the JAR file of the applet or application.

Package Sealing: A package within a JAR file can be optionally sealed, which means that all classes defined in that package must be archived in the same JAR file. A package might be sealed to ensure version consistency among the classes in your software or as a security measure.

To seal a package, a Name header needs to be added for the package, followed by a Sealed header, similar to this:

Name: myCompany/myPackage/
Sealed: true

The Name header's value is the package's relative pathname. Note that it ends with a '/' to distinguish it from a filename. Any headers following a Name header, without any intervening blank lines, apply to the file or package specified in the Name header. In the above example, because the Sealed header occurs after the Name: myCompany/myPackage header, with no blank lines between, the Sealed header will be interpreted as applying (only) to the package myCompany/myPackage. This code doesn't work.

Package Versioning: The Package Versioning specification defines several manifest headers to hold versioning information. One set of such headers can be assigned to each package. The versioning headers should appear directly beneath the Name header for the package. This example shows all the versioning headers:

Name: java/util/
Specification-Title: "Java Utility Classes" 
Specification-Version: "1.2"
Specification-Vendor: "Sun Microsystems, Inc.".
Implementation-Title: "java.util"
Implementation-Version: "build57"
Implementation-Vendor: "Sun Microsystems, Inc."


Specify Dependencies:

You can use the MANIFEST.MF file to specify all the classes that must be loaded for an application to be able to run. Source: the sun servlet specification, page 72 (servlet-2_4-fr-spec.pdf)

See also

References

  1. ^ http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html
  2. ^ http://download.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#JAR%20Manifest
  3. ^ http://download.oracle.com/javase/6/docs/technotes/guides/jar/jar.html

Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Manifest — has different meanings. It may refer to the following: Arts Manifest (convention), the Melbourne Anime Festival Business Manifest Limited, the UK marketing company Computing Manifest file, a file that contains information about accompanying files …   Wikipedia

  • Manifest (.NET Framework) — An assembly manifest is a text file containing metadata about .NET assemblies. It describes the relationship and dependencies of the components in the assembly, versioning information, scope information and the security permissions required by… …   Wikipedia

  • Manifest (computing) — Manifest is a file that contains metadata describing other applications or software components …   Wikipedia

  • File sharing and the law — The legal issues in file sharing involve violation of copyright laws as digital copies of copy written materials are transferred between users. The debate on peer to peer and file sharing is a virtually global phenomenon. Peer to peer ( P2P )… …   Wikipedia

  • Manifest von Manila — Das Manifest von Manila (auch Lausanne II genannt) ist das Schlussdokument des „Internationalen Kongresses für Weltevangelisation“ in Manila. Es gilt als die Fortschreibung und Aktualisierung der Lausanner Verpflichtung, einer freiwilligen,… …   Deutsch Wikipedia

  • manifest — 1. adjective /ˈmæn.ɪ.fɛst,ˈmæn.ə.fɛst/ a) Evident to the senses, especially to the sight; apparent; distinctly perceived. Calistho there stood manifest of shame. Dryden. b) Obvious to the understanding; apparent to the mind; easily …   Wiktionary

  • JAR (file format) — Infobox file format name = Java Archive icon = extension = .jar mime = application/java archive type code = uniform type = com.sun.java archive owner = Sun Microsystems genre = file archive, data compression container for = contained by =… …   Wikipedia

  • Legal aspects of file sharing — Part of a series on File sharing Technologies Peer to peer  …   Wikipedia

  • List of file formats — This is an incomplete list, which may never be able to satisfy particular standards for completeness. You can help by expanding it with reliably sourced entries. See also: List of file formats (alphabetical) This is a list of file formats… …   Wikipedia

  • OPF (file format) — OPF (Open Package File) defines the content of E Book System s FlipBook. It has 3 main sections :* Defines attributes applicable to the entire FlipBook * Defines page resources used in the section * Specifies an ordered list of pages in the… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”