0

So, my java project has the following hierarchy :

Project folder ------src-----PackageA-----MainClass (with main method)
          |       |
          |         -----PackageB------SecondClass
          ------resource----image.jpg

The src folder is on the classpath, but the resource folder is not(I don't know if this is the cause of my problem)

Here is the problem. When i try to use getResourceAsStream() from inside a method from SecondClass I get NullPointerException. I've tried

getClass().getResourceAsStream("/resource/image.jpg") getClass().getResourceAsStream("/Project folder/resource/image.jpg") getClass().getResourceAsStream("Project folder/resource/image.jpg")

and in all the paths returned null pointer. I am sure I am doing something wrong but I don't get what. Please, help me out! Thanks!

Adi Pascu
  • 33
  • 1
  • 7

0 Answers0