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
9
votes
1 answer

Can I use module-info.java if target level is 8?

I know that module-info.java is recognized by jdk9+ I wonder however whether module-info.java can still be used in combination with target level 8. E.g. I want my library to be used in java9+ projects, which will recognize it as a module exporting…
7
votes
1 answer

Wrong class invoked in Multi-release JAR file on Java 9?

I am seeing a problem with an Applet using a multi-release JAR, which I hope someone can help me with. I have a very simplified multi-release jar file with a class named VersionDependent. Its method "version" should display "Java 9 version" when…
Larry C.
  • 111
  • 4
5
votes
3 answers

Deploying multiple release .jar on Oracle WebLogic Server

We are trying to deploy a web service (a .war file) onto an Oracle WebLogic 12.2.1.0.0 Server. The .war contains some third party .jars, for example log4j-api-2.12.0.jar, that are multiple release .jars (per JEP 238, having Multi-Release: true in…
Matthew McPeak
  • 17,705
  • 2
  • 27
  • 59
5
votes
1 answer

Bytecode Scanning error on META-INF/versions/9/* and Elasticsearch 6.2.2+ with Jetty 9.2

Running GWT app in the Superdev mode with the latest versions of Elasticsearch (above 6.1.1) creates the following error (see below). It is clear that the issue has to do with the outdated version of Jetty. Does anyone know how to replace Jetty in…
4
votes
1 answer

java9 '-release 8' with internal packages (e.g. sun.misc.Unsafe)

I am trying to create a multi-release jar with Maven (3.8.0). We call sun.misc.Unsafe which compiles fine in java8 and java11. However, compiling with java11 --release 8 raises a Compilation failure: package sun.misc does not exist. Here is how to…
Rémi.B
  • 183
  • 10
3
votes
0 answers

How to setup an Eclipse project for create a multi-release jar file?

If I want build a multi-release jar file (MRJAR) then I need two source folder that compile with different java versions. How can I setup this in Eclipse? I can configure the Gradle build script for such building but what is the best practice for…
Horcrux7
  • 23,758
  • 21
  • 98
  • 156
3
votes
2 answers

cannot get log4j-api-java9

I'm building my project with Java11 and maven my pom look like this and i'm trying to get the right log4j-api for my project log4j-api is since 2.9 a multi-release jar with support of java9+ and older java versions In my project i still not able to…
Eltorrooo
  • 157
  • 2
  • 15
3
votes
2 answers

Multi-release log4j-api-2.11.0.jar on the the module-path in javadoc 10.0.2

I'm trying to javadoc code that contains a module-info.java that requires org.apache.logging.log4j;. I've included the jar from Maven Central that matches the coordinates "org.apache.logging.log4j:log4j-api:2.11.0 (which is a multi-release jar) on…
XDR
  • 4,070
  • 3
  • 30
  • 54
3
votes
1 answer

Multi-Release jars in gradle

I have been scratching my head for awhile trying to set up my library to use multi-release jars to use java 9+ features with backup java 8 implementations. However, it is only needed for a module of my project. My current build.gradle for the…
austinv11
  • 33
  • 1
  • 3
3
votes
1 answer

Can MR-Jars overwrite classes from other jars?

I have a jar that works on Java 8. I would like to create a new jar, that is going to be Multi-Release JAR but empty, just with 'patched' classes in META-INF/versions. I would like to have a separate jar, so people can include it on Java9,…
igr
  • 10,199
  • 13
  • 65
  • 111
2
votes
1 answer

Maven Shade does not include "META-INF/versions" of multi-release dependency

In our project, we create a "skinny" jar, which only includes our own application code and we use maven shade plugin to create the JARs for the dependencies we need to run the application. Maven shade is used to package multiple dependencies into…
Robert P
  • 9,398
  • 10
  • 58
  • 100
2
votes
1 answer

Building multi-release jar for a project involving dependencies

I am trying to build multi-release jar for a maven project involving external dependencies. The reason why I emphasize on "external dependencies" is because I succeeded in building multi-release jar following the instructions here:…
Krish
  • 63
  • 1
  • 7
2
votes
1 answer

Unable to create java 9 jars

if i run the command jar --create --release 9 -C com.java.mrjar.nine\build\classes . I have the error entry: META-INF/versions/9/com/java/mrjar/nine/Main.class, contains a new public class not found in base entries entry:…
MrSir
  • 576
  • 2
  • 11
  • 29
1
vote
0 answers

Is android system support multi-release jar?

I included a multi-release jar into app.libs and call the api in the jar(the api simply print current jdk version). But it didn't work. Will multi-release jar work in android? How to make it work?
黄柯睿
  • 11
  • 1
1
vote
1 answer

How to config IDEA to support Multi-Release Jar development

I am learning MRJar and trying to create a sample example which has folder structure as follow, both java folder and java9 folder are marked as source root └───main ├───java │ └───com │ └───test │ App.java │…
1
2