MRJAR short for Multi-Release JAR has been introduced in Java 9 for multiple release specific meta info specified in the metadata of the JAR. The tag would mostly be accompanied with Java-9 tag.
A JAR
file has a content root, which contains classes and resources, as well as a META-INF
directory which contains metadata about the JAR. By adding some versioning metadata to specific groups of files the JAR format can encode, in a compatible way, multiple versions of a library for different target Java platform releases. A multi-release JAR ("MRJAR") will contain the main attribute:
Multi-Release: true
declared in the main section of the JAR MANIFEST.MF
. The attribute name is also declared as a constant java.util.jar.Attributes.MULTI_RELEASE
. Like other main attributes, the name declared in the MANIFEST.MF
is case insensitive. The value is also case-insensitive, but there must be no preceding or trailing white space (such a restriction helps ensure the performance goal is met).
A multi-release JAR ("MRJAR") will contain additional directories for classes and resources specific to particular Java platform releases. A JAR for a typical library might look like this:
jar root
- A.class
- B.class
- C.class
- D.class
Suppose there are alternate versions of A and B that can take advantage of Java 9 features. We can bundle them into a single JAR as follows:
jar root
- A.class
- B.class
- C.class
- D.class
- META-INF
- versions
- 9
- A.class
- B.class