“Essential” (Jigsawed) Java 9 JRE without modularized code

匆匆过客 提交于 2019-12-06 05:57:36

问题


We have a Java application that does not use AWT/Swing/JavaFX and works fine with a private bundled JRE 8. JRE 9 is significantly larger than JRE 8 but we want to let the users try our application with JRE 9. We don't yet want to modularize our code or the jars (to keep compatibility with Java 8).

How to create an "essential" (= stripped down to the minimal required parts), private JRE 9 that could be bundled with that Java application?


回答1:


It is possible to create custom runtime-images of the JRE without having converted the application itself to Java 9 modules. First, we need to find out what modules (of the JDK/JRE) are needed:

"C:\Program Files\Java\jdk-9.0.1\bin\jdeps.exe"
                 -s
                 "C:\path\to\my\jars\*.jar"

Then we can create a light-weight jre directory structure (replace java.logging,java.xml with the modules required by your application):

"C:\Program Files\Java\jdk-9.0.1\bin\jlink.exe"
                 --module-path "C:\Program Files\Java\jdk-9.0.1\jmods"
                 --add-modules java.logging,java.xml
                 --output "e:\myproject\jre"


来源:https://stackoverflow.com/questions/48060773/essential-jigsawed-java-9-jre-without-modularized-code

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!