How to enable JavaFX in NetbeansIDE 11.3

515 Views Asked by At

I can't get JavaFX working with NetBeans 11.3.

The NetBeans documentation says:

If you install JavaFX 2.1 to Windows manually, consider installing the JavaFX 2.1 libraries and runtime to the default location (C:/Program Files/Oracle/). NetBeans IDE checks the default locations for the JavaFX. If JavaFX 2 is in the default locations the IDE can automatically create a JavaFX-enabled Java platform.

I've put the Gluon SDK there, though the number is 11.0.2. NetBeans does not automatically create a JavaFX enabled platform.

This StackOverflow answer suggests cleaning the cache. That didn't help.

If I try to create a new JavaFX project from the IDE, I get the message:

Failed to automatically set-up a JavaFX Platform. Please go to Platform Manager, create a non-default Java SE platform, then go to the JavaFX tab, enable JavaFX and fill in the paths to valid JavaFX SDK and JavaFX Runtime. Note: JavaFX SDK can be downloaded from JavaFX website.

But there is no "JavaFX" tab on the platform manager. The NetBeans release notes way back in version 8.0.2 say:

Unlike previous versions of NetBeans IDE, NetBeans IDE 8.0.2 does not require that you set up an "FX-enabled" Java platform in order to utilize JavaFX support in the IDE. You can develop JavaFX projects in the IDE if you install any standard Java platform that is JDK 7 Update 6 or newer (JDK 7 Update 10 or newer is strongly recommended).

But presumably that is from when JavaFX was bundled in the JDK.

So how do I get NetBeans to recognise the Gluon JavaFX?

1

There are 1 best solutions below

0
On

Manual workaround:

/nbproject/project.properties file

run.jvmargs=--module-path "D:\\Libraries\\Java9\\openjfx-13.0.2_windows-x64_bin-sdk\\javafx-sdk-13.0.2\\lib" \
--add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web \
--add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED \

// you may need to add more --ad-exports arguments based on the errors that will crop up during the run phase. this stuff basically removes package access limiters at runtime so be careful.

then there's the compiler arguments

javac.modulepath=\
    D:\\Libraries\\Java9\\openjfx-13.0.2_windows-x64_bin-sdk\\javafx-sdk-13.0.2\\lib

and i'm pretty sure you need this too

javac.classpath=\
${libs.JAVAFX13.classpath}:\