Error trying to use Javafx 11 with Netbeans 9.0

Asked

Viewed 3,802 times

2

I’m trying to update my version of Java to 11, but I cannot make it work on IDE.

This error appears when trying to create a new project.

I know that the JavaFX was taken from JDK from version 11, and which should be added as a library in the project, but the IDE does not even allow the creation of a new project displaying this error.

I didn’t find anything like this on Google, it’s probably some process I’m doing wrong.

How to solve?

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

Error image

1 answer

3

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 ToolsLibraries. 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.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.