Java 11 no longer comes with built-in Javafx. Starting with Java 11, Javafx 11 must be downloaded separately here.
If you’re using Maven, you can put this in your pom.xml
:
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>12-ea+7</version>
</dependency>
If you are using Gradle, you declare the dependency like this:
compile group: 'org.openjfx', name: 'javafx-base', version: '12-ea+7'
As described here, in Netbeans 9.0, you can choose the menu Tools → Libraries. On the screen that opens, click the button New Library..., name the library of JavaFX
and then add into this library the necessary Jars.
At least for me, Netbeans does not recognize Jmods, so to build the library in Netbeans you may need to disassemble the Jmods and repackage them in Jars for the Netbeans IDE to accept them.
Once the library is created in Netbeans, you can add it to new or existing projects.
When creating a new project with Javafx in Netbeans, do not choose a new Javafx project. Instead, use a new Java project and add Javafx. The reason is that the ANT scripts generated by Netbeans 9.0 are not compatible with Javafx 11.
There were several reasons why Javafx was removed from inside JDK to live separately:
Oracle no longer has any interest in developing Javafx. However, other developer groups do. So it made sense that Javafx would come out of Oracle’s possession.
The efforts from Java 8 are to reduce the size of the JDK and increase its modularization (culminating with the Java 9 modules). To achieve this goal, it was necessary for Javafx to live outside JDK.
It is interesting for both sides that Javafx releases are independent of JDK releases. Mandatory coupling of releases to each other was considered a drawback. Even, you can see versions of Javafx here.
Therefore, the decision taken in early 2018 would be that Javafx would be removed from within JDK. There was no time to remove it from Java 10 that would soon be released, so they decided that Java 10 would still include it, but it would be the last version to do so. Thus, Java 11 is the first version that no longer includes it.