Issue
I am new to Java Programming. Recently I created a JavaFX program using the latest JDK 15 (https://www.oracle.com/java/technologies/javase-downloads.html) and the latest JavaFX SDK 15 (https://openjfx.io/index.html). Suppose that I need to deploy the application (.jar) in someone else's computer.
- What is the version of JRE which should be in the client's PC? Or does he need to install complete JDK?
- My program contains VM options so that can I embed them within the .jar file?
- Are there specific JREs for version after Java 8? Or is the JRE coupled with the JDK itself?
Solution
From Java 9 onwards, Oracle no longer provides a JRE-only installation kit, either with the Oracle Java badge or the OpenJDK badge. That's why you can't find Java 15 JRE downloads on the Oracle and OpenJDK download sites.
You / they have three options:
- They can download and install a JDK for Java 15. You or he will also need to deal with the JavaFX JAR and other 3rd-party JARs that your application uses.
- You can use
jlink
(or similar) to turn your JAR file into an executable with an embedded (cut down) JRE. You then ship that executable rather than the JAR file. - You can recommend that they obtain Java from a 3rd party Java vendor that provides a JRE option for Java 15.
My program contains VM options so that can I embed them within the .jar file?
I don't think you can do that. But it should be a simple matter to write a shell script or batch file which calls (for example) java
with the required options.
If you use jlink
you can embed JVM options in the executable; see How to set VM options for JLink launcher executable.
The jpackage
tool may also be an option, though this is not a production feature until Java 16.
Answered By - Stephen C
Answer Checked By - Terry (JavaFixing Volunteer)