Hi i want to show image list with string in j2me and below is my code

public ListImage() {
try {
for (int i = 0; i < 2; i++)
img[i] = Image.createImage("/res/flag_" + i + ".png");
} catch (Exception e) {
System.err.println(e.getMessage());
}
}
Here u can see that image is in res folder and i am accessing image with /res/flag_ but i still get an error of Null Pointer Exception
Using Untrusted simulated domain
Cannot read /res/flag_0.png
java.lang.NullPointerException
at ListImage.startApp(+12)
at javax.microedition.midlet.MIDletProxy.startApp(+7)
null
null
null
java.lang.NullPointerException
at ListImage.startApp(+12)
at javax.microedition.midlet.MIDletProxy.startApp(+7)
null
In
J2ME,resis the Resource Directory for any image, data, etc files. It’s path isroot (/)by default. And hence not required to use it’s name in the path/res/MyImage.png. Instead call it as/MyImage.png.Example:
Refer to: