如何安裝和導入OpenJFX?


0

我已經安裝了 openjdk 11 openjfx (使用" apt get install openjfx")。
試圖在代碼中使用" import javafx" " import openjfx" ,並且 javac 總是說沒有這樣的軟件包。

1

There is a new way to work with JavaFX if you are using Java 11. This is their official web site: https://openjfx.io/openjfx-docs/#install-javafx

Inside is described how to:

  • Install Java 11 (JRE or JDK)
  • Download their JavaFX runtime from: https://gluonhq.com/products/javafx/
  • Export the path of the JavaFX runtime: export PATH_TO_FX=path/to/javafx-sdk-11/lib
  • compile and run java application with module path to the PATH_TO_FX and the necessary modules:

    • javac --module-path $PATH_TO_FX --add-modules javafx.controls (other javaFX modules) HelloFX.java

    • java --module-path $PATH_TO_FX --add-modules javafx.controls (other javaFX modules) HelloFX

For more information please visit their website read https://openjfx.io/openjfx-docs/#install-javafx and also read some information on java 9 module system.

Best luck to all!