The manifest, META-INF/MANIFEST.MF, is a UTF-8 text file of
Name: value headers. This page follows the JAR File Specification (Java SE
21, with the attributes that the Java SE 8 edition still listed), the
java.lang.instrument documentation for agent attributes. The same syntax is used by the signature files described on
signed JAR files.
Syntax
Headers are grouped in sections separated by empty lines. The first
is the main section, about the whole JAR; each further
individual section starts with Name: and is about one
entry.
section: *header +newline
nonempty-section: +header +newline
newline: CR LF | LF | CR (not followed by LF)
header: name ":" value
name: alphanum *headerchar
value: SPACE *otherchar newline *continuation
continuation: SPACE *otherchar newline
alphanum: {A-Z} | {a-z} | {0-9}
headerchar: alphanum | "-" | "_"
otherchar: any UTF-8 character except NUL, CR and LF
manifest-file: main-section newline *individual-section
main-section: version-info newline *main-attribute
version-info: "Manifest-Version :" version-number
version-number: digit+ { "." digit+ }*
individual-section: "Name :" value newline *perentry-attribute
- Line length. No line may be longer than 72 bytes in UTF-8. A
longer value continues on the next line, which starts with a single space (the space
is dropped when joining). A header name can be at most 70 bytes, since it cannot be
continued and must be followed by
:. - A value may be up to 65,535 bytes. Binary data is written in Base64.
- No header may start with
From(to survive e-mail). - Attribute names are not case-sensitive, but tools should write them as shown here; an attribute may not appear twice in one section.
Manifest-Version(andSignature-Versionin signature files) must come first, written exactly so. Other order does not matter.- The manifest must not list itself; every file to be signed must be listed. Several sections for the same entry are merged, the last value winning. Unknown attributes are ignored.
- A manifest that cannot be parsed should cause a warning, and no signature in the JAR should then be trusted.
Main attributes
| Attribute | Value and meaning |
|---|---|
Manifest-Version | Version of the manifest format, a version number; 1.0. |
Created-By | Version and vendor of the Java implementation that wrote the manifest, such as 21.0.2 (Eclipse Adoptium). |
Signature-Version | Version of the signature format (in a .SF file). |
Class-Path | Space-separated relative URLs of the JARs and folders the code needs; see Class-Path. At most one. |
Automatic-Module-Name | Module name to use when the JAR is an automatic module (a non-modular JAR on the module path); otherwise the name is derived from the file name. |
Multi-Release | true (any case) makes it a multi-release JAR; other values are ignored. |
Main-Class | Binary name of the class whose main method java -jar runs, without .class. |
Launcher-Agent-Class | An agent class in an executable JAR whose agentmain is called before main. |
Sealed | true or false: default sealing for every package in the JAR. |
Implementation-Title | Title of the implementation (package versioning; may be overridden per package). |
Implementation-Version | Version of the implementation. |
Implementation-Vendor | Organisation that maintains the implementation. |
Specification-Title | Title of the specification it implements. |
Specification-Version | Version of that specification. |
Specification-Vendor | Organisation that maintains that specification. |
Java agent attributes
| Attribute | Value and meaning |
|---|---|
Premain-Class | Agent class whose premain runs before main when the JAR is given with -javaagent; required then, or the JVM stops. |
Agent-Class | Agent class whose agentmain runs when the agent is loaded into a running JVM; required for that. |
Launcher-Agent-Class | See above. |
Boot-Class-Path | Space-separated paths (URI path syntax, relative to the agent JAR unless starting with /) for the bootstrap class loader to search. |
Can-Redefine-Classes | true or false (default): the agent needs to redefine classes. |
Can-Retransform-Classes | true or false (default): the agent needs to retransform classes. |
Can-Set-Native-Method-Prefix | true or false (default): the agent needs to set a native method prefix. |
Extension and applet attributes (removed)
The Java SE 8 specification also listed these, for the extension mechanism and applets, marking the applet mechanism as deprecated; the current specification no longer lists them.
| Attribute | Meaning |
|---|---|
Extension-Name | Unique name of the extension in the JAR, such as its main package. |
Implementation-Vendor-Id | Unique ID of the implementation’s vendor (deprecated). |
Implementation-URL | Where to download the implementation (deprecated). |
Extension-List | Space-separated short names of the extensions an applet needs; each name x then has the attributes below. |
x-Extension-Name | The extension’s Extension-Name. |
x-Specification-Version | Minimum specification version needed. |
x-Implementation-Version | Minimum implementation version needed. |
x-Implementation-Vendor-Id | Vendor whose implementation is needed. |
x-Implementation-URL | Where to download it if missing. |
Per-entry attributes
An individual section’s attributes apply to one entry, or, for a name ending in
/, to a package, and override main attributes of the same name.
| Attribute | Value and meaning |
|---|---|
Name | Required first: the entry’s path in the JAR (com/example/App.class), a package folder (com/example/), or an absolute URL of data outside the JAR. |
Content-Type | MIME type of the entry, type/subtype. |
Java-Bean | true or false: the entry is a JavaBean. |
Implementation-*, Specification-*, Sealed | As in the main section, for this package. |
x-Digest | Base64 digest of the entry’s bytes with algorithm x (a MessageDigest name, such as SHA-256-Digest or SHA1-Digest), written when the JAR is signed. |
x-Digest-y | A digest of a language variant y of the entry, such as SHA-256-Digest-French. |
Magic | Comma-separated, application-specific keywords saying how the digest was computed (such as Multilingual); a verifier must understand them to verify the entry. |
Class-Path
Each space-separated item is a URL relative to the JAR; an item ending in
/ is a folder, anything else a JAR. An item is used only if it resolves to
a URL, has no scheme (except file for a JAR loaded from the file system),
and stays inside the JAR’s folder (no ../, except for JARs loaded from the
file system). Invalid, missing and repeated items are ignored. The resolved items are
inserted into the class path straight after the JAR, and their own
Class-Path is followed the same way, lazily.
Example: with class path a.jar b.jar and b.jar declaring
Class-Path: lib/x.jar a.jar, the search order is a.jar b.jar
lib/x.jar.
Other attributes
The Java launcher and other tools read further main attributes that the JAR File
Specification does not define (such as Add-Exports,
Add-Opens and Enable-Native-Access in executable JARs).
They are not covered here; see the Java launcher documentation and the JEPs that
introduced them.
Package sealing
A sealed package must have all its classes in one JAR, or a
SecurityException is thrown; this also protects package-private members.
Sealed: true in the main section seals every package unless a package’s
section says Sealed: false; without the main attribute, packages are
unsealed unless their section says otherwise. The unnamed package cannot be
sealed.
Manifest-Version: 1.0
Created-By: 1.8 (Oracle Inc.)
Sealed: true
Name: foo/bar/
Sealed: false
foo.bar.Sources
JAR File Specification, Java SE 21 (“Name-Value pairs and Sections”, “JAR Manifest”,
“Main Attributes”, “Per-Entry Attributes”, “Class-Path Attribute”, “Package
Sealing”) and Java SE 8 (the extension and applet attributes);
java.lang.instrument package documentation, Java SE 21 (agent
attributes).