IntelliJ IDEA - getClass().getResource(“…”) return null

前端 未结 9 679
挽巷
挽巷 2020-12-15 16:21

I\'m using IntelliJ IDEA 13.1.5, I used to work with Eclipse. I\'m working on JavaFX application, I try to load FXML file within my MainApp class using getClass().getResourc

9条回答
  •  囚心锁ツ
    2020-12-15 16:47

    If your project is Gradle, check Settings -> Build, Execution, Deployment -> Gradle -> Build and run section. Ensure that "Build and run using" option is "Gradle".

    Intellij IDEA's compiler doesn't copy "resources" to build dir nor to tests classpath. Also, it unexpectedly uses dummy "out" dir instead of "build".

    UPDATED: only 1 option "Build and run using" is enough to set to Gradle.

提交回复
热议问题