【求助】新手求助,J2ME程序出现IOException错误
刚学J2ME,有一定C++基础。写了一个小程序,显示一张png格式的飞机图片。代码放在了两个java文件里,代码如下:testImage.java部分:
import
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
public class testImage extends Canvas {
Image img;
public testImage() throws IOException {
img = Image.createImage("/plane.png");
}
protected void paint(Graphics g) {
g.setColor(255,255,255);
g.fillRect(0, 0, getWidth(), getHeight());
g.drawImage(img, 50, 50, Graphics.LEFT | Graphics.TOP);
}
}
testImageMain部分:
import
import javax.microedition.lcdui.Display;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class testImageMain extends MIDlet {
testImage ti;
public testImageMain() throws IOException {
ti = new testImage();
Display.getDisplay(this).setCurrent(ti);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
protected void pauseApp() {
// TODO Auto-generated method stub
}
protected void startApp() throws MIDletStateChangeException {
// TODO Auto-generated method stub
}
}
我使用的编译器是Eclipse 3.5.2,在电脑上模拟的时候运行正常,显示出了图片,打包后把JAR文件放在手机上安装运行后直接出现“应用程序错误:”。我图片已经打包到了JAR文件里,我用WinRAR查看了,图片确实在里面。我测试的手机是诺基亚6700s,S60V3系统的。请各位高手帮帮我!我初学者。这样的错误对我打击太大了。