ClassLoader classload = getClassLoader().getResource("images/pic.png); URL url = classload.something.something(); String test = url.toString(); Image some = new ImageIcon(test).getImage();
This has led to some frustration since ( right now ) my program is messed up and it not working hehe. I'm thinking of making a GetResourceFromJar.java that would assume that the resource files are already in some jar. Does anybody has a better solution?
As long as both of your jar files are listed as resource, you should be able to use code like the following to access images:
I believe this would be the preferred method for loading properties files, images, etc that are bundled within jar files as you can use either ClassLoader.getResource(String) or ClassLoader.getResourceAsStream(String) to find them.
Joined: Apr 11, 2006
Hi, thanks for the help. I tried it for my image files and it worked but there seemed to be some problems for the text files and sound files.