What's the location of the JavaFX runtime JAR file, jfxrt.jar, on Linux?
Update March 2021
The previous information in this answer is now obsolete for later versions of Java and JavaFX (e.g. Java 11+). This update provides info for more recent versions.
JavaFX is now available from openjfx.io or the public Maven repository as an SDK or a library set, or a module set. JavaFX has been partitioned into a set of dependencies rather than a monolithic jfxrt.jar
library distributed with the Java runtime (as was previously the case with Oracle Java 8 for instance).
With versions 11+ of JavaFX, the location of the JavaFX jar files (and the native libraries to accompany them) will depend on how you build your project. For example:
- If you use a build tool such as Maven or Gradle and specify JavaFX as a dependency, then the JavaFX jar files will be downloaded into your local Maven or Gradle repository (the same as other maven dependencies).
- If you download the JavaFX SDK from openjfx.io (gluon), then the JavaFX jar files will be in the location you unzipped the SDK to.
The location of jfxrt.jar in Oracle Java 7 is:
<JRE_HOME>/lib/jfxrt.jar
The location of jfxrt.jar in Oracle Java 8 is:
<JRE_HOME>/lib/ext/jfxrt.jar
The <JRE_HOME>
will depend on where you installed the Oracle Java and may differ between Linux distributions and installations.
jfxrt.jar is not in the Linux OpenJDK 7 (which is what you are using).
An open source package which provides JavaFX 8 for Debian based systems such as Ubuntu is available. To install this package it is necessary to install both the Debian OpenJDK 8 package and the Debian OpenJFX package. I don't run Debian, so I'm not sure where the Debian OpenJFX package installs jfxrt.jar.
Use Oracle Java 8.
With Oracle Java 8, JavaFX is both included in the JDK and is on the default classpath. This means that JavaFX classes will automatically be found both by the compiler during the build and by the runtime when your users use your application. So using Oracle Java 8 is currently the best solution to your issue.
OpenJDK for Java 8 could include JavaFX (as JavaFX for Java 8 is now open source), but it will depend on the OpenJDK package assemblers as to whether they choose to include JavaFX 8 with their distributions. I hope they do, as it should help remove the confusion you experienced in your question and it also provides a great deal more functionality in OpenJDK.
My understanding is that although JavaFX has been included with the standard JDK since version JDK 7u6
Yes, but only the Oracle JDK.
The JavaFX version bundled with Java 7 was not completely open source so it could not be included in the OpenJDK (which is what you are using).
In you need to use Java 7 instead of Java 8, you could download the Oracle JDK for Java 7 and use that. Then JavaFX will be included with Java 7. Due to the way Oracle configured Java 7, JavaFX won't be on the classpath. If you use Java 7, you will need to add it to your classpath and use appropriate JavaFX packaging tools to allow your users to run your application. Some tools such as e(fx)clipse and NetBeans JavaFX project type will take care of classpath issues and packaging tasks for you.
How to run a jar that uses JavaFx with the --enable-preview tag in cmd/terminal?
Thanks to help in the comments & this blog, adding the following to your VM arguments:
--module-path path/to/your-version-of-javafx/lib" --add-modules javafx.controls,javafx.fxml
and running the following command in cmd/terminal
java --enable-preview --module-path path/to/your-version-of-javafx/lib" --add-modules javafx.controls,javafx.fxml -jar MyProgram.jar
Allows the jar run without errors.
The blog also has other solutions/methods to dealing with this problem as well.
JavaFX .jar works on Windows and OSX but not on Linux
So, turns out the problem was that the JRE on the Linux machine was OpenJDK, which does not come with JavaFX, as noted by James_D and jewelsea
After installing the oracle JRE 8, it worked fine
JavaFX is NOT part of the JDK 14
JavaFX was removed from JDK since JDK 11.
Since JDK 9, java is modular.
JavaFX was split into modules.
Hence there is no longer a single jfxrt.jar
file. There are several JAR files, one for each module.
Related Topics
Animation on Transparent-Background Jframe Linux
Why Does Java Rmi Keep Connecting to 127.0.1.1. When Ip Is 192.168.X.X
How to Kill This Tomcat Process in Terminal
Fill an Array With Random Numbers
Unsatisfiedlinkerror When Using Jni
Create a File Using Runtime.Exec Using Echo in Linux
Why How to Successfully Move a File in Linux While It Is Being Written To
Image Encryption/Decryption Using Aes256 Symmetric Block Ciphers
Running a Scheduled Task Written in Java on a Linux Server
Installing Jdk8 on Ubuntu- "Unable to Locate Package" Update Doesn't Fix
Swt Expandlistener Executes Before Collapse Occurs on Linux
How to Abort the Installation of an Rpm Package If Some Conditions Are Not Met in Specfile
Could Not Create the Java Virtual MAChine