Java 9 : multi-release JAR files
As of now, JAR files can contain classes that can only run on the Java version they
were compiled for. To leverage the new features of the Java platform on newer
versions, the library developers have to release a newer version of their library.
Soon, there will be multiple versions of the library being maintained by the
developers, which can be a nightmare. To overcome this limitation, the new feature
of multirelease JAR files allows developers to build JAR files with different versions
of class files for different Java versions. The following example makes it more clear.
Here is an illustration of the current JAR files:
jar root
Here is how multirelease JAR files look:
jar root
- A.class
- B.class
- C.class
- META-INF
- versions
- 9
- A.class
- 10
- B.class
In the preceding illustration, the JAR files support class files for two Java versions--9
and 10. So, when the earlier JAR is executed on Java 9, the
under the
A.class
versions
folder is picked for execution. On a platform that doesn't support multirelease
- 9
JAR files, the classes under the versions directory are never used. So, if you run the
multirelease JAR file on Java 8, it's as good as running a simple JAR file.
were compiled for. To leverage the new features of the Java platform on newer
versions, the library developers have to release a newer version of their library.
Soon, there will be multiple versions of the library being maintained by the
developers, which can be a nightmare. To overcome this limitation, the new feature
of multirelease JAR files allows developers to build JAR files with different versions
of class files for different Java versions. The following example makes it more clear.
Here is an illustration of the current JAR files:
jar root
- - A.class
- - B.class
- - C.class
Here is how multirelease JAR files look:
jar root
- A.class
- B.class
- C.class
- META-INF
- versions
- 9
- A.class
- 10
- B.class
In the preceding illustration, the JAR files support class files for two Java versions--9
and 10. So, when the earlier JAR is executed on Java 9, the
under the
A.class
versions
folder is picked for execution. On a platform that doesn't support multirelease
- 9
JAR files, the classes under the versions directory are never used. So, if you run the
multirelease JAR file on Java 8, it's as good as running a simple JAR file.
Comments
Post a Comment