简体   繁体   中英

Javafx cannot be resolved in Eclipse although working with JavaFX Library

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM