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

前端 未结 9 737
挽巷
挽巷 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:34

    As per suggestion, updated answer.

    Step-1

    1. Right click on project
    2. Click on Mark Directory as
    3. Click on Sources Root

    Step-2

    1. Click on File in Menu Bar
    2. Click on Project Structure… to open settings panel

    Step-3

    1. Click on Modules tab
    2. As you see there isn’t any resources folder added as Content Root
    3. We need to add resources folder into it

    Step-4

    1. Make sure to click on resource folder
    2. Click on Resources tab after that
    3. You will see resources folder added as Resource Folders in right panel

    Re-run your java program and now it should work.

    <---Previous Answer---->

    Fixed similar issue today by adding resources folder into Resource Tab in IntelliJ IDE

    Hope this helps. Also, details tutorial.

提交回复
热议问题