Questions tagged [multi-release-jar]

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
26 questions
1
vote
1 answer

Viewing version source for multi release JAR (MRJAR)

I'm trying to attach the Java 9 or Java 11 source for some projects released as MRJARs, namely jersey-container-jetty-http-3.0.2 and junit-platform-commons-1.4.0. Looking at the jersey-container-jetty-http-3.0.2-sources.jar file in my…
Loren_
  • 2,597
  • 3
  • 20
  • 29
1
vote
3 answers

AWS Lambda using incorrect classfiles from a Multi-Release JAR?

I've had a lambda running for a few years under Java8, and I just updated it to Java 11. It immediately broke, giving me errors like: Caused by: java.lang.ExceptionInInitializerError at…
Andrew Rueckert
  • 4,858
  • 1
  • 33
  • 44
1
vote
0 answers

Multi-Release-War for tomcat8 on jdk10

I just read about Multi-Release-Jars what looks like a good advantage. I can not get it working using a Tomcat8 on JDK10 and not getting a stacktrace. This is my servlet (placed at webapp.jar!/META-INF/versions/10/de/NanoNanoServlet.class): package…
Grim
  • 1,938
  • 10
  • 56
  • 123
0
votes
0 answers

Does proguard support multirelease jars?

We have a multirelease .jar that contains different .class files under META-INF/versions (e. g. META-INF/versions/9/org/apache/logging/log4j/util/StackLocator.class). After running proguard in version 7.2.1, the META-INF/versions folder in the…
user27772
  • 522
  • 1
  • 4
  • 18
0
votes
1 answer

Code for different Java versions in same Gradle Project

Is it possible to create a Gradle Project in a way so that the major part can be used with one Java version (e.g. Java 11) while some parts rely on a higher Java version (e.g. Java 17) and can only be used by clients with Java 17? It should be…
dan1st
  • 12,568
  • 8
  • 34
  • 67
0
votes
0 answers

jar is not a multi-release jar file but --multi-release option is set

On running mvn package in the root directory I am getting following errors- Error: async-http-client-2.12.1.jar is not a multi-release jar file but --multi-release option is set [ERROR] Failed to execute goal…
0
votes
0 answers

UnsupportedClassVersionError occurs when executing Jar files that support JDK8 and JDK11 created with Multi Release Jar with Maven

We created a Jar File that supports two versions of JDK8 and JDK11 using the "Multi Release Jar Files with Maven" technology and executed it, but the following error appears. Exception in thread "main" java.lang.UnsupportedClassVersionError: [our…
0
votes
1 answer

Create multi-release jar using maven profiles

I am trying to create a multi-release jar with maven and it's compiler plugin. I would like to control which JDKs are targeted through the use of profiles. I created two profiles, one for jdk8 and the other jdk11, as well as a build plugin…
Alex Barker
  • 4,316
  • 4
  • 28
  • 47
0
votes
0 answers

JPMS/Jigsaw-compatible Java library targeting older JDKs

I'm trying to figure out how to use Maven to build a library jar file that is compatible with JDK 7 and 8 but includes a module-info.java file an explicitly declares its public API. Problem: I need to compile for old target versions but the old JDKs…
0
votes
1 answer

Error while creating multi release jar "entry: A.class, contains a class with internal name com.vipin.exp.A, names do not match"

Here java9/com/vipin/exp/A.class is file I want to use with jdk 9 and for other versions java8/com/vipin/exp/A.class. For this I am trying to create multi release jar but getting below error. What is wrong in this command…
Vipin
  • 4,851
  • 3
  • 35
  • 65
-2
votes
1 answer

Multi-release jar files without multiple sets of source code

I want to create a multi-release JAR file for a library. I will build the MRJAR using maven - and initially it will contain Java 8 and Java 9 class files. BUT - I do not want to maintain two separate sets of source code (e.g. in src/main/java-8 and…
tbsalling
  • 4,477
  • 4
  • 30
  • 51
1
2