Beanshell java.lang.NoClassDefFoundError
我在beanshell中编写了java代码,但它通过定义DefaultHandler抛出java.lang.NoClassDefFoundError。我已经导入了它,我不明白为什么会抛出这个异常。我的代码如下所示:
import org.xml.sax.helpers.DefaultHandler;
try {
XMLReader xr = XMLReaderFactory.createXMLReader();
**DefaultHandler handler = new DefaultHandler() {
variables
.........
methods(){
..................
}
};**
InputSource file = new InputSource(new StringReader(stringResult));
xr.setContentHandler(handler);
xr.parse(file);
} catch (Ex e) {
.........
}
谢谢
i wrote java code in beanshell but it throws java.lang.NoClassDefFoundError by defining DefaultHandler. I have already imported it, i don't understand why is this exception thrown. My Code looks like here:
import org.xml.sax.helpers.DefaultHandler;
try {
XMLReader xr = XMLReaderFactory.createXMLReader();
**DefaultHandler handler = new DefaultHandler() {
variables
.........
methods(){
..................
}
};**
InputSource file = new InputSource(new StringReader(stringResult));
xr.setContentHandler(handler);
xr.parse(file);
} catch (Ex e) {
.........
}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
导入它和将它放在 CLASSPATH 中是两件截然不同的事情。编译时,您可能已经在 CLASSPATH 中找到了它,但如果运行时不存在,就会出现问题。
Importing it and having it in your CLASSPATH are two very different things. You might have had it in CLASSPATH when you compiled, but if it's not there at runtime you'll have an issue.
执行二进制文件时正确设置类路径。
设置类路径
Set the Class path correctly while you execute the binaries.
Setting the Class path