I have no problems loading an image from a jar using a class which
shares that jar. However, if I have a utility jar which contains a
ImageLoader utility class and use this class from my main application
jar which contains the images, I get a null pointer exception on
createImage.
( I'm using the utility class's class loader and calling the get
resource method. ) I don't get a problem running my application
jar-less in Eclipse.
When I got this error I assumed that by default you can only load a
resource from the same jar. So, I put the images into the utility jar
too, but to no avail - the same error.
Anyone got any pointers? Is there a way of loading resources from other
jars as I'm trying to do?
many thanks in advance.
JavaEnquirer - 22 Feb 2006 15:03 GMT
I've just tried passing the class loader of the application ( whose jar
contains the images ) to the ImageLoader class in the utility jar for
it to use. This doesn't seem to work either. Is there any mileage in
looking at the URLClassLoader class?
JavaEnquirer - 22 Feb 2006 15:42 GMT
I've come across a suggestion that I ensure that my application.jar is
included in the class path of my utility.jar. This way, the ImageLoader
in utility.jar can load images from application.jar as requested by
application.jar. I'd like to avoid this as utility jars shouldn't be
coupled to code that may call them.