I am trying to understand how java paths work in eclipse but I am terribly confused.
I have an image troll.png
and I am using ImageIO.read(getClass().getResourceAsStream("troll.png"))
to access it.
Now, if I put troll.png
in the same package as the classes I use it in, it works. But I want to place it in another folder, so I made a folder resources
in the project, parallel to the src
folder where I keep my classes.
How can I read an image from that folder? I've tried every path I could think of and none worked.