"Essential" (Jigsawed) Java 9 JRE without modularized code
Asked Answered
C

1

5

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?

Corrode answered 2/1, 2018 at 12:11 Comment(13)
To clarify - are you looking for something other than the standard Oracle JRE because that's too big?Prohibitory
Yes, I thought this was obvious.Corrode
Well it more or less is obvious, but then I don't understand what you mean in that bit about code optimization.Prohibitory
Well, we don't want to modularize our code or the jars yet (because then we would expect problems with Java 8), just the JRE.Corrode
It sounds like you're asking if you can use the Module System without having your code organized as Modules? Is that correct?Fic
The question isn't really clear to me in terms of what exactly your end goal is and what way are you trying to achieve the same. Could you please update it to elaborate further?Vaccaro
Have you looked at the jlink tool in JDK 9?Lamberto
I have updated the question to answer your questions.Corrode
According to your updates Alans comment is probably still the one to look at more closely.Bernat
According to docs.oracle.com/javase/9/tools/jlink.htm the jlink requires modular jar files which we don't have.Corrode
This could be something you're looking for on what I could wildly figure out from the current context. Though for We don't yet want to modularize our code or the jars (to keep compatibility with Java 8) => you can take a look at MR-JARs.Vaccaro
You can run a run-time image created by jlink to run a non-modular application. The important thing is to make sure that the run-time image has all the standard/JDK modules that you need.Lamberto
The question is how to build such a run-time-image for the application.Corrode
C
7

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"
Corrode answered 4/1, 2018 at 11:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.