Le chargement de l'image en Java J2ME

J'ai un problème avec le chargement de l'image avec java 2ME. J'ai un fichier image "une image.png" emplacement dans le disque "C:". Après que j'ai écrit comme ça pour afficher une image à partir de cet emplacement.

import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
public class ImageMidlet extends MIDlet implements CommandListener{
private Display display;
private Command exitCommand;
private Command backCommand;
private Command okCommand;
private Form form;
private ImageItem imageItem;
private Image image;
public ImageMidlet(){
display = Display.getDisplay(this);
form=new Form("");
exitCommand = new Command("Exit", Command.EXIT, 1);
backCommand = new Command("Back", Command.BACK, 2);
okCommand = new Command("OK", Command.OK, 3);
try {
image=Image.createImage("/picture.png");
imageItem=new ImageItem(null,image,ImageItem.LAYOUT_NEWLINE_BEFORE,"");
}
catch(IOException ex){
}
form.append(imageItem);
form.addCommand(okCommand);
form.addCommand(exitCommand);
form.addCommand(backCommand);
form.setCommandListener(this);
display.setCurrent(form);
}
public void commandAction(Command c,Displayable d){
}
public void startApp() {
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}

Il m'indique cette erreur:

Unable to create MIDlet Test.ImageMidlet
java.lang.NullPointerException
at javax.microedition.lcdui.Form.append(Form.java:638)
at Test.ImageMidlet.<init>(ImageMidlet.java:39)
at java.lang.Class.runCustomCode(+0)
at com.sun.midp.midlet.MIDletState.createMIDlet(+34)
at com.sun.midp.midlet.Selector.run(Selector.java:151)

Je commence à apprendre à développer, de sorte s'il vous plaît guide pour ce faire.

vérifiez le nom de fichier est correct. Chargeur d'Image est sensible à la casse et même le nom de fichier "image.Png", vous obtiendrez l'exception...

OriginalL'auteur Sopolin | 2009-08-26