getClassLoader().getResource() does not load images
843802May 12 2005 — edited May 17 2005I am working on converting our application to work with JavaWebStart on JRE 1.4.2_05 and have hit a brick wall and need some insight as to why I am having problems.
When I load an image file using the following code I get the URL object back as expected:
MyClass.class.getResource("image.jpg")
However, when I use any of the below methods to load the image, the URL object returned is always null.
this.getClass().getClassLoader().getResource("image.jpg");
Thread.currentThread().getContextClassLoader().getResource("image.jpg");
MyClass.class.getClassLoader().getResouce("image.jpg");
The first two of the list above are mentioned in the JavaWebStart FAQ http://java.sun.com/products/javawebstart/faq.html#54.
I can honestly find no explicit reference to the working method and why it should work when the others don't. Can anyone here explain why it works when the others don't? I have to change some third party library software to use the first working method if I can't find a reason such as a bug ID telling me I need to upgrade the JRE or something that would explain the logic behind why it is working this way.
Thanks,
Eric Laabs