一个问题,请高手指点!

richluo 2004-12-03 04:29:49
由于工作需要我要在J2ME中使用SIP协议,所以在NOKIA网站上下载了一个sip的API.其中自带了一个example 我把sipAPI加到了WTK中,想运行一下它自带的例子.具体操作是在WTK中创建一个工程,把代码拷到文件夹中,然后build ,都没有问题.可是只要Run 就出现错误了,错误信息如下:
Unable to create MIDlet ReceiveMessage

java.lang.ClassNotFoundException: ReceiveMessage

at com.sun.midp.midlet.MIDletState.createMIDlet(+14)

at com.sun.midp.midlet.Selector.run(+22)
为什么会找不到类呢???
我在moto的模拟器中运行也出现错误,其中一行是这样的:
Unable to load class javax/microedition/sip/SipClientConnectionListener

一个例子的代码如下:
import java.util.*;
import java.io.*;
import javax.microedition.io.*;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;

import javax.microedition.sip.*;

public class SendMessage extends MIDlet implements CommandListener, SipClientConnectionListener {

private Display display;
private long startTime;
private Form form;
private TextField address;
private TextField subject;
private TextField message;
private Command sendCmd;
private Command exitCmd;

public SendMessage() {
System.out.println("MIDlet: SendMessage starting...");
display=Display.getDisplay(this);
form = new Form("Message example");
address = new TextField("Address", "sip:user@10.128.0.50:5070", 30, TextField.LAYOUT_LEFT);
subject = new TextField("Subject", "test", 30, TextField.LAYOUT_LEFT);
message = new TextField("Message text", "test message...", 30, TextField.LAYOUT_LEFT);
form.append(address);
form.append(subject);
form.append(message);
sendCmd = new Command("Send", Command.ITEM, 1);
form.addCommand(sendCmd);
exitCmd = new Command("Exit", Command.EXIT, 1);
form.addCommand(exitCmd);
form.setCommandListener(this);
}


public void commandAction(Command c, Displayable d) {
if(c == sendCmd) {
Thread t = new Thread() {
public void run() {
sendMessage();
}
};
t.start();
}
if(c == exitCmd) {
destroyApp(true);
}
}

public void startApp() {
display.setCurrent(form);
System.out.println("MIDlet: SendMessage startApp()");
}

private void sendMessage() {
SipClientConnection sc = null;
try {
sc = (SipClientConnection) Connector.open(address.getString());
sc.setListener(this);
String text = message.getString();
sc.initRequest("MESSAGE", null);
sc.setHeader("Subject", subject.getString());
sc.setHeader("Content-Type", "text/plain");
sc.setHeader("Content-Length", ""+text.length());
OutputStream os = sc.openContentOutputStream();
os.write(text.getBytes());
os.close(); // close and send out
startTime = System.currentTimeMillis();

} catch(Exception ex) {
ex.printStackTrace();
}
}

public void notifyResponse(SipClientConnection scc) {
try {
System.out.println("MIDlet: waited "+(System.currentTimeMillis()-startTime)+" secs");
scc.receive(1);
form.append("notifyResponse: "+scc.getStatusCode()+" "+scc.getReasonPhrase());
scc.close();
} catch(Exception ex) {
form.append("MIDlet: exception "+ex.getMessage());
}
}

public void pauseApp() {
System.out.println("MIDlet: pauseApp()");
}
public void destroyApp(boolean b) {
System.out.println("MIDlet: destroyApp()");
notifyDestroyed();
}

}
到底是怎么回事呢,情给予指点!
...全文
66 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
richluo0928 2005-01-04
  • 打赏
  • 举报
回复
hao
richluo 2005-01-04
  • 打赏
  • 举报
回复
ding
richluo 2004-12-03
  • 打赏
  • 举报
回复
classpath中jdk配置正确. 代表当前目录的".;"也有了 还差什么吗?
redex 2004-12-03
  • 打赏
  • 举报
回复
检查检查classpath.

13,100

社区成员

发帖
与我相关
我的任务
社区描述
Java J2ME
社区管理员
  • J2ME社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧