我都快要急疯了!!我的j2me程序,老是出错。现附例题一则,请帮我看看:

fengyang 2001-09-27 05:14:41
我都快要急疯了!!我的j2me程序,用j2me wireless toolkit 可以built通过,但是run时,总是出错:null exception:java.lang.nullpointer Exception.我用的都是一些书上或网上的例题,但是都出这样的错误。
/*
* HelloWorld.java
*
* June 27, 2000
*
* ? Copyright 2000 Motorola, Inc. All Rights Reserved.
* This notice does not imply publication.
*/

package com.mot.j2me.midlets.tutorials;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

/**
* A simple Hello World midlet
*
* @see MIDlet
*/

public class HelloWorld extends MIDlet {
/**
* Main application screen
*/

private Form mainScreen;
/**
* A reference to the Display
*/

private Display myDisplay;
/**
* Creates a screen for our midlet
*/

HelloWorld() {
myDisplay = Display.getDisplay(this);
mainScreen = new Form("Hello World");
/*
* Create a string item
*/
StringItem strItem = new StringItem
("Hello", "This is a J2ME MIDlet.");
mainScreen.append(strItem);
}

/**
* Start the MIDlet
*/
public void startApp() throws MIDletStateChangeException {
myDisplay.setCurrent(mainScreen);
}

/**
* Pause the MIDlet
*/
public void pauseApp() {
}

/**
* Called by the framework before the application is unloaded
*/
public void destroyApp(boolean unconditional) {
}

}

...全文
76 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
XHGosling 2001-09-28
I have run your codes rightly.
com.sun.midp.midletsuite.MIDletSuiteImpl.loadInitialMIDlet
need your consturctor add the "public" key word!
回复
XHGosling 2001-09-28
constructor HelloWorld() need add public key word,
or your environment of project setting is error,
you can see the demo setting and set it.
回复
lhdyf 2001-09-28
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.lang.*;

public class HelloWorld extends MIDlet implements CommandListener
{

private Form mainScreen;


private Display myDisplay;


public HelloWorld()
{
myDisplay = Display.getDisplay(this);
mainScreen = new Form("Hello World");
StringItem strItem = new StringItem("Hello", "This is a J2ME MIDlet.");
mainScreen.append(strItem);
}
public void startApp()
{
myDisplay.setCurrent(mainScreen);
}
public void pauseApp()
{
}


public void destroyApp(boolean unconditional)
{
}
public void commandAction(Command c,Displayable d){}
}
回复
fengyang 2001-09-27
怎么用?
回复
rockswang 2001-09-27
用printStackTrace定位你出错的语句!
回复
fengyang 2001-09-27
o!没人回答!!
回复
相关推荐
发帖
J2ME
创建于2007-09-28

1.3w+

社区成员

Java J2ME
申请成为版主
帖子事件
创建了帖子
2001-09-27 05:14
社区公告
暂无公告