Reputation: 15078
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
Upvotes: 1
Views: 725
Reputation: 23982
In J2ME
, res
is the Resource Directory for any image, data, etc files. It's path is root (/)
by default. And hence not required to use it's name in the path /res/MyImage.png
. Instead call it as /MyImage.png
.
Example:
Image img = Image.createImage( "/MyImage.png" );
Refer to:
Upvotes: 2