Java9 Features – Part 3 | Multi-release Jar | Example

Finally a good news for library maintainers..!! Multi-release Jar extends the JAR file format to allow multiple, Java-release-specific versions of class/resource files to coexist in the same archive.

Before JAVA9 

  • A JAR file contains a content root that stores class and/or resource files.
  • JDK only observes the content root’s class files.

In JAVA9

  • A Multi-release Jar file contains a content root that stores class and/or resource files.
  • It also contains META-INF, a sub-directory of the content root that stores metadata about the JAR file.
  • MANIFEST.MF file in includes the entry Multi-Release: true in its main section.

Also Read:- where this name JAVA came from?
Example :-

  • I have 2 Java class files A.class and B.class which I developed long ago.
  • Today in A.class I update code which uses Java 9 feature.

  • A pre-Java 9 JDK only observes the content root’s class files; it doesn’t see the Java 9-specific A.class file.
  • In contrast, a Java 9 JDK sees first the version 9 A.class file and then sees the content root A.class and B.class files.

Also Read :- Difference between Interface of Java7, Java8 and Java9
Future Scope

  • A pre-Java 9 JDK only observes the content root’s class files; it doesn’t see the Java 9-specific A.class file.
  • Java 9 JDK sees first the version 9 A.class file and then sees the content root A.class and B.class files.
  • Java 10 JDK sees first the version 10 A.class file and then sees the content root A.class and B.class files.

Also Read :
Java9 Features part I | JShell | Private Method in Interface | Try with Resource updation
Java9 Features part II | Collection Factory Methods

But Wait, there is still more. Yes, there is still more and this time you don’t have to wait for weeks. The IV part should be done in few days and it will focus on safevarargs and improvement in @Deprecated.

I am positive that newsletter will give a sneak peak so if you are curious then subscribe. If you like this article, help us spread the world and tell a friend about it.

This is what you are looking for? click below

One thought on “Java9 Features – Part 3 | Multi-release Jar | Example

Leave a Reply

Your email address will not be published. Required fields are marked *