Problem with getResource Method
807607Jan 4 2007 — edited Jan 4 2007Hello frds,
i m using follwg code to load images in my swing comp..
This code is working properly when i m trying to run my application using simple run command.
I added one print statement to check the getResource method.
that is working fine when run my application using run command.
But when i m trying to launch my application using jar file.
getResource method is not working & returning URL is null.
I m using getProperties to load images.
Please try to solve this prob.
Protected Static ImageIcon createImageIcon(String path)
{
ClassLoader cl = MP3Display.class.getClassLoader();
URL imgURL = cl.getResource(path);
System.out.println("SURBHI : Test URL" + imgURL + " ---" +path);
if(imgURL !=null)
{
return new ImageIcon(imgURL);
}
else
{
System.err.println("Could't find file "+path);
return null;
}
}