How to get the version number of JavaFX?

后端 未结 3 1495
清歌不尽
清歌不尽 2020-11-30 04:18

How can I find out at runtime which version of JavaFX I\'m using?

相关标签:
3条回答
  • 2020-11-30 05:06

    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
    
    0 讨论(0)
  • 2020-11-30 05:11
    com.sun.javafx.runtime.VersionInfo.getRuntimeVersion();
    
    0 讨论(0)
  • 2020-11-30 05:16

    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.

    0 讨论(0)
提交回复
热议问题