Java9 versions with a warning message informing that both classes are the same. C:\Users\User\tutorialspoint>jar--create--fileMR.jar-Csampleproject-basedemo--release9-Csampleproject-9demoWarning"/> Java9 versions with a warning message informing that both classes are the same. C:\Users\User\tutorialspoint>jar--create--fileMR.jar-Csampleproject-basedemo--release9-Csampleproject-9demoWarning">

Home  >  Article  >  Java  >  How can we create a multi-release jar (mrjar) using the jar tool in Java 9?

How can we create a multi-release jar (mrjar) using the jar tool in Java 9?

WBOY
WBOYforward
2023-09-16 19:21:031139browse

我们如何使用Java 9中的jar工具创建一个多版本发布的jar(mrjar)?

In Java 9, a new feature "Multi-version jar format" has been introduced in which different versions of Java classes can be used or maintainable resources to enhance the jar format and use it according to the platform. The jar command can be used to create a multi-version jar containing two versions of the same class compiled for Java 8 and >Java 9 Version comes with a warning message informing that the two classes are identical.

<strong>C:\Users\User\tutorialspoint>jar --create --file MR.jar -C sampleproject-base demo --release 9 -C sampleproject-9 demo
Warning: entry META-INF/versions/9/demo/SampleClass.class contains a class thatis identical to an entry already in the jar</strong>

" --release 9" option can tell the jar to include all the following content (the demo package in the "sampleproject-9" directory ) in "## Within the versioned entry of MRJAR under #root/META-INF/versions/9”.

<strong>jar root
   - demo
      - SampleClass.class
   - META-INF
      - versions
         - 9
            - demo
               - SampleClass.class</strong>

The above is the detailed content of How can we create a multi-release jar (mrjar) using the jar tool in Java 9?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete