This content has been marked as final. Show 4 replies
have you checked the class location to tell from where your code attempts to read the image. It looks as if the directory structure is not found
I think that was the problem and I've been changing classpath, the code, ... with no prevail. Here is the directory structure:
D:\ConvertJdeveloper\Class5272\Assignment2\classes\A2. This is where all the classes are.
From your comment, I just moved image folder to A2 folder. So all my image files are at
This also caused the exception (using the same code that I posted).
What is the issue then?
Thanks for the help
getResource() will load resources relative to classpath, not to file system.
If your classes are in A2 package then path is getResources("/A2/images/lightning/1.jpg")
That works. Thanks Dario and Frank.