How to find out JavaFX version


This should be easy, but I can't figure out how. Is there any way to find out which JavaFX version is installed. And I DON'T mean programmatically via System.getProperty("javafx.runtime.version") , which returns an empty string on my computer, although JavaFX is installed.

I would rather like to have something like java -version on console, but in order to get the JavaFX version.

Alternatively it would be sufficient to know if JavaFX is installed at all. I just have some customers who can't run my swing/javaFX app and would like to tell them to check whether JavaFX is installed.

4/24/2014 2:44:17 PM

Accepted Answer

You can't really do this the same way you do with the Java runtime. The difference is that java is a machine executable that launches the JVM. JavaFX is just a set of library classes; it's not really an executable in the same sense.

It looks like the System property that you can read at runtime is kept in jre/lib/, so you can do something like

cat $JAVA_HOME/jre/lib/

or whatever the Windows equivalent is, if you're running on Windows. However, if the System property you get at runtime is blank, then I suspect this file doesn't exist. As dfeuer commented, it would help to know your JRE version.

Update: The relationship between JDK/JRE version and JavaFX version is as follows.

Beginning with JRE 1.7.0 update 6, JavaFX was included with the JRE, but was not on the classpath. So for JRE 1.7.0, update 6 and later, the jfxrt.jar file is included in JAVA_HOME/jre/lib. The file which contains the JavaFX version information is in the same directory, though in theory at least the JRE version will determine the JavaFX version (since they were shipped together).

Just inspecting the JDK 1.7.0 versions I have installed on my machine, the mapping from JDK version to JavaFX version is:

/Library/Java/JavaVirtualMachines/jdk1.7.0_06.jdk   javafx.runtime.version=2.2.0
/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk   javafx.runtime.version=2.2.4
/Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk   javafx.runtime.version=2.2.4
/Library/Java/JavaVirtualMachines/jdk1.7.0_13.jdk   javafx.runtime.version=2.2.5
/Library/Java/JavaVirtualMachines/jdk1.7.0_17.jdk   javafx.runtime.version=2.2.7
/Library/Java/JavaVirtualMachines/jdk1.7.0_21.jdk   javafx.runtime.version=2.2.21
/Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk   javafx.runtime.version=2.2.25
/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk   javafx.runtime.version=2.2.40
/Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk   javafx.runtime.version=2.2.45

Beginning with JRE 1.8.0, JavaFX was included with the JRE and was placed on the classpath; so it's effectively a full part of the core libraries. In version 1.8.0, the jfxrt.jar file is in JAVA_HOME/jre/lib/ext (which automatically makes it part of the classpath). The file which contains the JavaFX version information is still in JAVA_HOME/jre/lib. The version numbering for JavaFX in version 1.8.0 (appears to) simply mimic the JRE version:

/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk  javafx.runtime.version=8.0.0
/Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk   javafx.runtime.version=8.0.5
/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk   javafx.runtime.version=8.0.20

So with your customers, you can simply ask them to do java -version and for the most part, you'll be able to deduce the JavaFX version. On some rare occasions you may need to dig a little deeper.

A sort-of-related note: if you are shipping an application to customers and you need to determine a specific version, consider using a self contained application, in which you include a JRE (and JavaFX runtime) with the application.

4/24/2014 3:49:45 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow