“基本" (已拼图)没有模块化代码的Java 9 JRE [英] "Essential" (Jigsawed) Java 9 JRE without modularized code
问题描述
我们有一个不使用AWT/Swing/JavaFX的Java应用程序,并且可以与私有捆绑的JRE 8一起正常工作.JRE9明显大于JRE 8,但是我们想让用户使用JRE 9来尝试我们的应用程序.我们还不想模块化我们的代码或jar(以保持与Java 8的兼容性).
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).
如何创建可以与该Java应用程序捆绑在一起的必需的"(=精简到最少的必需部分)私有JRE 9?
How to create an "essential" (= stripped down to the minimal required parts), private JRE 9 that could be bundled with that Java application?
推荐答案
可以创建JRE的自定义运行时映像,而无需将应用程序本身转换为Java 9模块.首先,我们需要找出需要哪些模块(JDK/JRE的):
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"
然后,我们可以创建一个轻量级的jre
目录结构(将 java.logging,java.xml 替换为您的应用程序所需的模块):
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"
这篇关于“基本" (已拼图)没有模块化代码的Java 9 JRE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!