Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » 移动互联网  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 我被这个问题困扰好几天了,请各位帮帮我吧,谢谢!
richluo





发贴: 1
积分: 0
于 2004-11-30 12:35 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
异常:Cannot create class in system package。是怎么回事啊?
我在学习Nokia一个用sip传输消息的demo。把其中的代码copy到eclipse里面。把包package com.nokia.phone.ri.sip.examples去掉并换成默认的包。没有报错,可是在run的时候却发生错误,错误如下:
Running with storage root DefaultColorPhone
java.lang.NoClassDefFoundError: SendMessage: javax/microedition/sip/SipClientConnectionListener: Cannot create class in system package
at com.sun.midp.midlet.MIDletState.createMIDlet(+14)
at com.sun.midp.midlet.Scheduler.schedule(+52)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+116)
Execution completed.
456980 bytecodes executed
3 thread switches
489 classes in the system (including system classes)
2694 dynamic objects allocated (79008 bytes)
3 garbage collections (60308 bytes collected)

代码如下:

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();
}

}

这到底是怎么回事啊!!大家谁能帮我看看,谢了!



作者 Re:我被这个问题困扰好几天了,请各位帮帮我吧,谢谢! [Re:richluo]
itren





发贴: 23
积分: 10
于 2004-12-09 15:59 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
你没有打包成 jar的吧..



flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923