# What is a Multi-Release jar(mrjar) in Java 9?

JavaObject Oriented ProgrammingProgramming

A multi-release jar(also known as mrjar) contains the same release of a library for multiple Jdk versions. It means that we can have a library as mrjar that works for Jdk 9. The code in mrjar contains class files compiled in Jdk 9. The classes compiled with Jdk 9 may take advantage of APIs offered by Jdk 9.

The mrjar can extend the already existing directory structure of a jar. It contains a root directory where all its contents reside and the META-INF directory that has used to store metadata about the jar. Typically, a jar contains a META-INF/MANIFEST.MF file that contains attributes.

The entries in a jar as below:

- jar-root
- C1.class
- C2.class
- C3.class
- C4.class
- META-INF
- MANIFEST.MF

In the above template, the jar contains four class files and a MANIFEST.MF file. The mrjar extends the META-INF directory to store classes that can be specific to the Jdk version. The META-INF directory contains version sub-directory that contains many sub-directories, each of them named the same as Jdk major version. For instance, the classes specific to Jdk 9, there is a META-INF/versions/9 directory. For classes specific to Jdk 10, there is META-INF/versions/10.

- jar-root
- C1.class
- C2.class
- C3.class
- C4.class
- META-INF
- MANIFEST.MF
- versions
- 9
- C2.class
- C5.class
- 10
- C1.class
- C2.class
- C6.class
Published on 20-Mar-2020 10:24:52