First, preface
When you package multiple. class files into a jar package by executing a form such as the jar-cvf src.jar src command, you will find that the jar package has more than one mate-inf/mainfest in addition to the SRC directory. MF, what's that for?
In fact, the description information about the jar package, the configuration information at startup and security information are all kept under Meta-inf, so it is important to understand the Meta-inf directory for publishing and deployment! The following is only part of the content of the collation, and later in-depth practice after the completion of the supplement. The official documents are: http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html
Second, Meta-inf/mainfest. MF Manifest file Composition element
Meta-inf/mainfest. The MF manifest file consists of 1 main-section and 0 to n individual-section , and each section contains a plurality of attribute components, of which main-section the attribute in is named Main-attribute , and attribute in individual-section is named Perentry-attribute .
Use <CR><LF> as a delimiter between each attribute (use <LF> as a delimiter under UNIX and <CR> as a delimiter under Mac).
individual-section identifies the range with a perentry-attribute named name, and acts as the starting row for the zone.
Example:
1.0 Created 1.2 truename:foo/bar/false
main-section is used to describe the security, configuration information, and default information for all packages and files within a jar package.
Each individual-section is used to describe a single package or file in a jar package, but not every package and file in the jar package must be configured with individual-section , However, for files that need to be signed, the corresponding individual-section must be configured.
Three, Main-attribute detailed
1. General properties
mainfest-Version:jar Version number created-by: Producer Signature-version: Signature Version class-path: List of dependencies, Spaces are separated if there are multiple dependencies. The dependency path is a relative path to the reference system with the JAR package path
2. Executable Jar Package Properties
The fully qualified class name where the Main-class:main function resides
Four, Perentry-attribute detailed
1. the Name property , the starting property of the individual-section , the package naming specification, such as: com/test/myapp/, file naming specification, such as: com/test/myapp/ Myapp.class.
2. define file Contents
Content-type:mime type (in the format: Type/subtype. For example, Image/jpeg)
Five, matters needing attention
1. Key-value pairs occupy one or more rows independently;
2. The maximum length of each line is 72 characters;
3. The last character of each line must end with a carriage return newline character, and the carriage return newline character cannot have spaces (using regular expressions to express each line specification is/^.+\s\r\n$/);
4. If the key-value pair occupies more than one row, then from the second line, you must start with a space or more (the specification for expressing the second row and the remaining lines using regular expressions is/^[]{1,}.+\s\r\n$/).
Respect the original, reprint please indicate from: http://www.cnblogs.com/fsjohnhuang/p/4046856.html ^_^ Fat Boy John
Reference
http://blog.csdn.net/zhifeiyu2008/article/details/8829637
Http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html
Java Magic Hall: the meta-inf/mainfest of packaging knowledge points. Mf