Java cannot find JavaFx classes although present in JDK

前端 未结 1 812
北荒
北荒 2021-01-16 03:49

I am currently working on an application using javafx for its UI. I am using java 9. When I pulled from github to continue development on my new computer and compiled, there

相关标签:
1条回答
  • 2021-01-16 04:05

    Your IDE may have set the project up as a "modular" Java 9 project. In modular projects, you specify which other modules the project depends on, and which packages in your module(s) should be exposed to other modules. A good general tutorial on modules is at the OpenJDK wiki.

    If there's a module-info.java file in the classpath root, you need to explicitly state that your module requires access to the appropriate JavaFX modules. It may be enough just to add

    requires javafx.controls ;
    

    to this file: that will give you access to the javafx.controls module, and the modules on which it depends (javafx.graphics and javafx.base). Depending on your project, you may also need

    requires javafx.fxml ;
    

    and/or

    requires javafx.web ;
    

    etc.

    0 讨论(0)
提交回复
热议问题