JavaFX 為 Java 繼 Awt, Swing 之後推出的第3代圖形介面(GUI)套件。 利用 NetBeans 整合開發環境(IDE)撰寫 JavaFX應用時,常遇到開發環境如何建立的問題。很容易會遇到如下錯誤:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.controls not found
以下整理幾點 NetBeans 整合 JavaFX SDK,SceneBuilder 場景建立器,詳查 Build 腳本的方法,供除錯參考。
✅ NetBeans 整合 JavaFX SDK 方法 Project Properties Libraries/ Java Platform: JDK xx (Default) Compile/Compile-time Libraries: Classpath: JavaFX yy Run/Run-time Libraries: Modulepath: JavaFX yy Run/ Configuration: <default config> VM Options: --add-modules javafx.controls,javafx.fxml,javafx.media ✅ NetBeans 整合 SceneBuilder 方法 Tools/Options/Java/JavaFX JavaFX Scene Builder Integration Scene Builder Home: C:\Users\zz\AppData\Local\SceneBuilder ✅ NetBeans除錯想看Build執行腳本內容 Tools/Options/Java/Ant: Ant Home: ... [v] Always Show Output Verbosity Level: Quiet/Normal/[Verbose]/Debug 即可觀看Ant Target (build.xml) Output 註: 建立 JavaFX 開發環境所須安裝套件如下 1.OpenJDK https://learn.microsoft.com/zh-tw/java/openjdk/download microsoft-jdk-21.0.5-windows-x64.msi (不含JavaFX) https://www.azul.com/downloads/?package=jdk-fx#zulu zulu21.38.21-ca-fx-jdk21.0.5-win_x64.msi (含JavaFX) 2.NetBeans https://netbeans.apache.org/download/index.html Apache-NetBeans-22-bin-windows-x64.exe 3.SceneBuilder https://gluonhq.com/products/scene-builder/ SceneBuilder-23.0.1.msi 4.JavaFX SDK https://gluonhq.com/products/javafx/ openjfx-17.0.13_windows-x64_bin-sdk.zip