How to get the version number of JavaFX?

One of simple ways is to simply read the javafx.properties file located in your $JAVA_HOME/jre/lib directory.

I have Java 1.7 u9 installed at the moment. JavaFX bundled with it is v2.0.3 so the abovementioned file contains the following line:

javafx.runtime.version=2.0.3

com.sun.javafx.runtime.VersionInfo.getRuntimeVersion();

You can get the javafx.runtime.version number from a System Property.

import javafx.application.Application;
import javafx.stage.Stage;
public class ReportVersion extends Application {
  public static void main(String[] args) { launch(args); }
  @Override public void start(Stage stage) {
    System.out.println("javafx.runtime.version: " + System.getProperties().get("javafx.runtime.version"));
    System.exit(0);
  }
}

Note that the System Property access method may cause a security exception if an unsigned application is embedded in a browser or accessed via WebStart, so Sergey's com.sun call may be better even though all com.sun calls are deprecated and not part of the official JavaFX public API.

Update

@assylias comments on Sergey's answer would seem to indicate that Sergey's com.sun may cause a security exception if an unsigned application is embedded in a browser or accessed via WebStart. So perhaps there is no good solution to determining the javafx runtime version when running under those specific conditions.