ClassLoader. GetResource("Resources/stop. Gif") probably cannot find the specified resource.
When this happens, it returns null hence the NullPointerException.
ClassLoader. GetResource("Resources/stop. Gif") probably cannot find the specified resource.
When this happens, it returns null, hence the NullPointerException.
This answer is correct, I forgot about case sensitivity in file names. – Malfist Jun 14 at 18:37.
The problem is that the VM is not able to find the resource named "Resources/stop. Gif". The reason for this is that the stop.
Gif file is located in the package "Resources" as it is in the base of the JAR file. By default, the getResource method will start with the package of the class from which the classloader was retrieved. In the case of your code it would be the package in which the Thread class is located.
The end result would be that the VM looks for the image in the location "/java/lang/Resources/stop. Gif", which is not where your image is located. If you are looking for a fixed location, i.e.
, Resource directory located in base of JAR, then make sure to prefix your URL string with '/' as in: classLoader. GetResource("/Resources/stop. Gif"); Another thing to think about is whether you need to use the ClassLoader from the current Thread.
Typically the ClassLoader used by your application class would be more appropriate. You can retrieve that by executing something similar to this.getClass(). GetResource(...).
That's not true. My application doesn't have a package, and once I corrected the case for the filename, it worked correctly. – Malfist Jun 14 at 18:46 You are correct that the answer was incorrect in the case of the context class loader.
I forget that invoking the ClassLoader's getResource directly performed different search logic than invoking the Class's getResource method. In the case of calling a Class's getResource method, the answer is correct. Although in your case of not using a package for your application, it would not matter either way.
– Kris Babic Jun 14 at 19:33.
ClassLoader. GetResource("Resources/stop. Gif") probably cannot find the specified resource.
When this happens, it returns null hence the NullPointerException .
The problem is that the VM is not able to find the resource named "Resources/stop. Gif". The reason for this is that the stop.
Gif file is located in the package "Resources" as it is in the base of the JAR file. By default, the getResource method will start with the package of the class from which the classloader was retrieved. In the case of your code it would be the package in which the Thread class is located.
The end result would be that the VM looks for the image in the location "/java/lang/Resources/stop. Gif", which is not where your image is located.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.