急!毫无头绪 java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserException

slj_0721 2008-05-11 09:08:07

import javax.microedition.midlet.*;
import javax.microedition.io.*;
import javax.microedition.lcdui.*;
import java.io.*;
import org.xmlpull.v1.*;



public class XmlRead extends MIDlet {

private Display display;
private String url = "http://192.168.1.100/myxml/index.xml";
XmlPullParserFactory factory;
XmlPullParser xpp;

public XmlRead() {
display = Display.getDisplay(this);

}

public void startApp() {
try {
downloadPage(url);
} catch (IOException e) {
// handle the exception
}
}

private void downloadPage(String url) throws IOException{
InputStream is = null;
HttpConnection c = null;
TextBox t = null;

try {

c = (HttpConnection) Connector.open(url);
is = c.openInputStream();

factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
xpp = factory.newPullParser();
xpp.setInput(is,null);
int eventType = xpp.getEventType();
while (true) {
switch (eventType) {
case XmlPullParser.START_DOCUMENT:
System.out.println("Start of Document");
break;
case XmlPullParser.START_TAG:
System.out.println("Start of Tag" + xpp.getName());
break;
case XmlPullParser.END_TAG:
System.out.println("END_TAG" + xpp.getName());
break;
case XmlPullParser.TEXT:
System.out.println("Text" + xpp.getText());
break;

}
if (eventType == XmlPullParser.END_DOCUMENT)
break;
eventType = xpp.next();
}
}catch(XmlPullParserException e){

}
finally {
is.close();
c.close();
}

display.setCurrent(t);
}

public void pauseApp() {
}

public void destroyApp(boolean unconditional) {
}

}

一旦运行 就会出现:

java.lang.NoClassDefFoundError: org/xmlpull/v1/XmlPullParserException
at com.sun.midp.midlet.MIDletState.createMIDlet(+29)
at com.sun.midp.midlet.Scheduler.schedule(+52)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)
Execution completed.
3384842 bytecodes executed
21 thread switches
1670 classes in the system (including system classes)
17661 dynamic objects allocated (532624 bytes)
2 garbage collections (458536 bytes collected)

代码没有语法错误,程序还没进到代码中就异常退出了。怎么会这样啊,是eclipse没配置好吗
...全文
855 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
wangchunhui407 2008-05-12
  • 打赏
  • 举报
回复
你打包时是不是没有把你下载的那个JAR包进去?
slj_0721 2008-05-12
  • 打赏
  • 举报
回复
这是什么意思
caused by: XmlPullParserException: resource not found: /META-INF/services/org.xmlpull.v1.XmlPullParserFactory make sure that parser implementing XmlPull API is available; nested exception is:
XmlPullParserException: resource not found: /META-INF/services/org.xmlpull.v1.XmlPullParserFactory make sure that parser implementing XmlPull API is available
slj_0721 2008-05-12
  • 打赏
  • 举报
回复
还是不行
java.lang.Error: Unresolved compilation problem:

at XmlPullParserFactory.newInstance(+9)
at XmlRead.downloadPage(+26)
at XmlRead.startApp(+8)
at javax.microedition.midlet.MIDletProxy.startApp(+7)
at com.sun.midp.midlet.Scheduler.schedule(+270)
at com.sun.midp.main.Main.runLocalClass(+28)
at com.sun.midp.main.Main.main(+80)
Execution completed.

是工具没有配置好吗
懒得抠虱子 2008-05-12
  • 打赏
  • 举报
回复
去下载源码,把源码加到你的项目中试试吧。
slj_0721 2008-05-11
  • 打赏
  • 举报
回复
有啊,有这个类
奇伢 2008-05-11
  • 打赏
  • 举报
回复
org/xmlpull/v1/XmlPullParserException
那你在KXMK中能找到org.xmlpull.v1.XmlPullParserException这个类吗?
slj_0721 2008-05-11
  • 打赏
  • 举报
回复
类库我有啊,KXML2,而且已经加到CLASSPATH中了,不会是这个问题
老紫竹 2008-05-11
  • 打赏
  • 举报
回复
如果你有这个jar,那么加入到你的CLASSPATH里面去。
老紫竹 2008-05-11
  • 打赏
  • 举报
回复
去 http://www.xmlpull.org/ 下载一个支持的jar吧
你的程序缺少这个类库

13,100

社区成员

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

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