Thursday, 15 September 2011

java - Get a resource using getResource() -



java - Get a resource using getResource() -

i need resource image file in java project. i'm doing is:

url url = testgametable.class.getclass(). getclassloader().getresource("unibo.lsb.res/dice.jpg");

the directory construction following:

unibo/ lsb/ res/ dice.jpg test/ ..../ /* other packages */

the fact file doesn't exist. have tried many different paths, couldn't solve issue. hint?

testgametable.class.getresource("/unibo/lsb/res/dice.jpg"); leading slash denote root of classpath slashes instead of dots in path you can phone call getresource() straight on class.

java resources getresource

No comments:

Post a Comment