0

I'm using Gradle and IntelliJ. I have a project with the following structure:

MyProject
   -src
     -main
       -java
         -com
           -app
             -resources
               -myfile.json

I want to read myfile.json, but there is no way to make it work. I already know that I can create the resource folder, using the resource folder works properly. But this is a legacy project and I can't change it right now.

I'm using the following to load the resource

Thread.currentThread().getClass().getResourceAsStream("/com/app/resources/myfile.json")

But I was not able to make it work. I've even changed my configuration Intelij like this Intelij Configuration

  • 1
    Move your `src/main/java/com/app/resources` folder to `src/main/resources` as per https://docs.gradle.org/current/userguide/java_plugin.html#sec:java_project_layout – Alex Jun 30 '21 at 16:31
  • Thank you for your suggestion, but as I mentioned before, I know that this will work. The only thing that I don't know is why some other computers are working with the environment I've exemplified here but not and mine. – Jonatas Fischer Jul 01 '21 at 07:57
  • Try to adjust the `build.gradle` as outlined in https://stackoverflow.com/a/32266152/410939. – Alex Jul 01 '21 at 12:33

0 Answers0