IntelliJ can't recognize JavaFX 11 with OpenJDK 11

前端 未结 4 2131
星月不相逢
星月不相逢 2020-11-22 01:57

I\'m having trouble getting IntellJ to recognize JavaFX packages. With a new JavaFX project, with OpenJDK 11, when trying to build the project, IntelliJ can\'t recognize the

4条回答
  •  渐次进展
    2020-11-22 02:18

    The issue that JavaFX is no longer part of JDK 11. The following solution works using IntelliJ (haven't tried it with NetBeans):

    1. Add JavaFX Global Library as a dependency:

      Settings -> Project Structure -> Module. In module go to the Dependencies tab, and click the add "+" sign -> Library -> Java-> choose JavaFX from the list and click Add Selected, then Apply settings.

    2. Right click source file (src) in your JavaFX project, and create a new module-info.java file. Inside the file write the following code :

      module YourProjectName { 
          requires javafx.fxml;
          requires javafx.controls;
          requires javafx.graphics;
          opens sample;
      }
      

      These 2 steps will solve all your issues with JavaFX, I assure you.

    Reference : There's a You Tube tutorial made by The Learn Programming channel, will explain all the details above in just 5 minutes. I also recommend watching it to solve your problem: https://www.youtube.com/watch?v=WtOgoomDewo

提交回复
热议问题