开发者

Java Manifest Files

I am trying to make sense 开发者_如何学编程of these files, I can seem to find reading that makes it simple to understand and remember. Could someone explain manifest files, and why they were created? Explanation on bundles would be appreciated as well.

Please and thank you


"Manifest" in Java usually means the META-INF/MANIFEST.MF file inside a jar file.

It adds meta-data about the .jar file and its content.

The most common use is probably to specify the main class of the jar file (via the Main-Class attribute) to allow the jar file to be executed directly (using java -jar myFile.jar).

Other uses are:

  • store hashes of stored files for signature validation
  • sealing jar files (i.e. ensure that only classes from this jar file are loaded in the packages defined in this jar file).
  • store version/product/producer information to be readable at runtime

This general Java mechanism is explained in this tutorial.

Since you also mention bundles, it might be possible that you're actually talking about an OSGi Bundle Manifest, which builds on top of that mechanism to turn a simple jar file into a bundle (a.k.a "a module", sometimes "a plugin").


On the Java platform , a Manifest file is a specific file contained within a JAR archive. 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 .


As far as I know manifest are used:

  • to provide human readable info about a particular jar: like version, producer, jdk it was built against, maybe id of continuous integration server's build and so on
  • to provide machine readable info like module dependencies in framework like OSGi

Most of that info is usually bot human and machine readable anyway.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜