J Woodchucks answer addresses Java 7 and 8. This answer just addresses Java 9+.
For JRE 9+, jfxrt.jar
does not exist and is replaced by .jmods
in the <JRE_HOME>/jmods
directory. This was done as part of JDK modularization. Additional required native libraries for JavaFX are included in the <JRE_HOME>/lib
directory. JavaFX will not work without the required native libraries.
You can use the full JRE runtime provided by a vendor such as Oracle (and probably a third party OpenJDK provider such as an Ubuntu or Redhat JRE package). This will include all required modules and libraries to run JavaFX as well as some that form part of the JRE but are not necessarily required to run a JavaFX application.
Note, for Java 8, some OpenJDK vendors chose not to include the JavaFX runtime as part of their Java distributions, requiring either an install of an additional package a custom build of the OpenJDK or a switch to a java runtime which does include JavaFX (such as the Oracle JRE). Hopefully, for Java 9, all OpenJDK vendors will provide full JRE runtimes that include JavaFX but you might need to wait until the OpenJDK vendors release generally available Java 9 runtimes to find out.
It is possible to create a custom modular runtime for JavaFX with Java 9 which eliminates some JRE modules that your application may not need. A custom modular runtime for JavaFX requires the javafx.*
modules that you wish to use, any dependent modules of those modules and any necessary native libraries. You can package your JavaFX application with a custom runtime using the JavaFX packager. The packaging technique of the JDK 9 javafxpackager is based upon the Java 9 module system; the internal implementation of which uses the java linker.
The java packager can further package the custom runtime as part of a self-contained application install package (if desired). A self-contained application contains your Java or JavaFX application and the JRE needed to run the application.
Once Java 9 undergoes its general availability release, I am sure that Oracle will provide some further official documentation and samples that demonstrates how to create a custom modular runtime for a JavaFX application and use it as part of a self-contained application.
Additionally, third party vendors such as gluon provide tools to package applications with custom JavaFX runtimes on various devices such as iPads and Android phones.