Reputation: 53
I'm working on a project in Eclipse where I use the JavaSE-14
Modulepath and JavaSDK
Classpath. However, every time I try to import a class from JavaFX
it says the import javafx cannot be resolved
. Any help? I'm new to programming in Java so please elaborate your answer.
Upvotes: 2
Views: 6151
Reputation: 15196
JavaFX is now a separate bundle to JDK so if you wish to use JDK14 with Eclipse then download a compatible JavaFX SDK. JavaFX 15.0.1 requires JDK 11 or later.
Then set up your project build path - right mouse on project: Build Path > Configure Build Path
.
In Libraries tab it is easier to define a variable: Add Variable JAVAFXLIB and pick the lib dir of your JavaFX release - example: set JAVAFXLIB to C:/java/javafx-sdk-15/lib
.
Then use the variable in the Module Path or Class Path of your project - example JAVAFXLIB/javafx.base.jar
.
If you plan to release your application you may want to get hold of the JavaFX jmods
release as well. Then you can use jlink
to package Java runtime with your JavaFX dependencies as one unit - this will simplify your runtime-environment.
Upvotes: 2