Java getResource () class with eclipse

I am trying to get getResource to work correctly all this morning, but for now, the only way I had to work is to move the res folder to the bin folder and then use getResource like this

URL url = MyClass.class.getResource("/res/gfx/entity/entity1.png");

But can't I make res reside outside the bin folder?

+5
source share
2 answers

Nevermind, I can’t believe how stupid the correction was.

I added the res folder to the main project folder, not to bin, and then went into eclipse

run> run configurations> classpath> select user entries> advanced> add folders> select res

then when I called the folder from res, instead of doing "/res/gfx/entity/entity1.png", I did "/gfx/entity/entity1.png"

!

+13

Java /res .

Plugin build.properties.

Dynamic Web /res WebContent.

+3

All Articles