Reputation: 51
I've been banging my head on this one for ages and all of the tutorials I've found don't seem to work. When I try to create a new JavaFX project in Netbeans 14, using JDK 18 and the latest JFX download for Windows here: https://gluonhq.com/products/javafx/
Also tried with JDK and JFX 17 and still no luck. I get this error:
I've added the libraries like so:
If I try to add the platform folder, it won't let me progress through the dialogue:
I can't find solutions to this anywhere and, again this is the same with JDK 17 and 18, and JFX 17 and 18. I've checked the documentation and there's nothing that seems to solve the issue.
It says to go to the JavaFX tab and enable JavaFX, but there's no JavaFX tab... Unless they mean this:
But if that's it then, as you can see, it's already enabled and it's still not working. I'm totally lost. I don't understand why the documentation is so poor for FX, for every IDE. It's honestly like they don't want people to use it and every tutorial I'm finding is using outdated versions of NetBeans, the JDK and JFX D-: (they also don't solve the issue even if I do follow them).
If anyone could help guide me, I'd really appreciate it.
Upvotes: 4
Views: 6801
Reputation: 205775
I strongly endorse the approach using maven suggested here. This project started exactly the same way; I'd welcome learning of any issues you encounter.
Alternatively, follow the steps outlined in JavaFX and NetBeans: Non-modular projects: IDE. You've created a JavaFX library, but "Don't try to create a JavaFX project." Instead, choose Java with Ant and Java Application to create a new project, shown below, then follow the remaining steps carefully. It's a convenient alternative for a scratch project while you assay maven.
Addendum: The ant code for a JavaFX project, not selected in the image above, may attempt to package dependencies that are no longer required. In particular, a project using module javafx.web
may fail with the following error, seen here and here.
Unable to create javax script engine for javascript.
The easiest fix is to recreate the enclosing project by choosing either of these:
Java with Ant > Java Project with Existing Sources
Java with Maven > Project with Existing POM
Alternatively, a simple example using a custom ant script is cited here.
Upvotes: 2
Reputation: 231
The answer is given in the docs:
"Warning: Don't try to create a JavaFX project. The JavaFX Ant tasks of the current Apache NetBeans version are not ready for JavaFX 11+ yet, unless you have a custom JDK that bundles JavaFX, as described in Custom JDK+JavaFX image."
https://openjfx.io/openjfx-docs/
Upvotes: 3
Reputation: 13859
I would suggest you go to New Project
-> Java with Maven
-> either Simple JavaFX Maven Archetype(Gluon)
or FXML JavaFX Maven Archetype(Gluon)
. Use the POM
to change your version of JavaFX
from the default to whatever version you like. I also use the POM
to change the JavaFX-Maven-Plugin
to the latest version.
Upvotes: 6