Open Java jar File We can often see that there is a meta-inf directory in the file, there are some files in this directory, There must be a MANIFEST.MF, this file describes a lot of information about the jar file, the following will detail the contents of the MANIFEST.MF file, first look at Struts.jar contains MANIFEST.MF file contents:
manifest-version:1.0
Created-by:apache Ant 1.5.1
Extension-name:struts Framework
Specification-title:struts Framework
Specification-vendor:apache Software Foundation
specification-version:1.1
Implementation-title:struts Framework
Implementation-vendor:apache Software Foundation
Implementation-vendor-id:org.apache
implementation-version:1.1
Class-path:commons-beanutils.jar Commons-collections.jar Commons-dig
Ester.jar Commons-logging.jar Commons-validator.jar Jakarta-oro.jar s
Truts-legacy.jar
If we classify the configuration information in the manifest, we can sum up the following major categories:
I. GENERAL Properties
1. Manifest-version
The version used to define the Manifest file, for example: manifest-version:1.0
2. created-by
Declares the creator of the file, which is typically generated by the JAR command line tool, such as: Created-by:apache Ant 1.5.1
3. Signature-version
Defining a signed version of a JAR file
4. Class-path
The application or class loader uses this value to build the internal class search path
two. Application-related properties
1. Main-class
Defines the entry class for the jar file, which must be an executable class that can be run by Java-jar X.jar Once the property is defined.
three. Small program (applet) related properties
1. Extendsion-list
This property specifies a list of extended information that is required by the applet, and each name in the list corresponds to the following properties
2. <extension>-extension-name
3. <extension>-specification-version
4. <extension>-implementation-version
5. <extension>-implementation-vendor-id
5. <extension>-implementation-url
four. Extended Identity Properties
1. Extension-name
This property defines the identity of the jar file, such as the Extension-name:struts Framework
Five. Package Extended Properties
1. Implementation-title defines the title of the extension implementation
2. Implementation-version defines the version of the extension implementation
3. Implementation-vendor defines an organization that extends the implementation
4. Implementation-vendor-id defines the identity of the organization that extends the implementation
5. Implementation-url: Define the Download address (URL) of the expansion pack
6. Specification-title defines the title of the extension specification
7. Specification-version defines the version of the extension specification
8. The Specification-vendor declares the organization that maintains the specification
9. Sealed defines whether the jar file is sealed and the value can be true or false (which I don't quite understand)
Six. Signature-related properties
Signature attributes We can refer to a section of the Mail.jar provided by JavaMail
Name:javax/mail/address.class
Digest-algorithms:sha MD5
sha-digest:ajr7rqnn//cdygouxbd06msvfi4=
md5-digest:zntiq2aqatsniowxi1pqpw==
This section defines the class name of the class signature, the algorithm name of the computed digest, and the corresponding summary content (encoded using the BASE64 method).
Seven. Custom Properties
In addition to some of the attributes mentioned earlier, you can also add your own attributes and the value of the response in MANIFEST.MF, such as the J2ME program jar package that might contain the following information
microedition-configuration:cldc-1.0
Midlet-name:j2me_mobber MIDlet Suite
Midlet-info-url:http://www.javayou.com
Midlet-icon:/icon.png
Midlet-vendor:midlet Suite Vendor
MIDlet-1: Mobber,/icon.png,mobber
midlet-version:1.0.0
microedition-profile:midp-1.0
Midlet-description:communicator
The key is how we read this information. In fact, the JDK provides us with an API for handling this information, For more information, see the Java.util.jar package, we can get manifest information by passing the path of a jar file to Jarfile and then invoking the Jarfile Getmanifest method.