JSONObject等实例崩溃 [英] JSONObject etc instantiation crashing
问题描述
我试图学习如何使用JSON并编写一个简单的程序,但是每当实例化JSON对象时,它就会崩溃. 如果在尝试实例化JSONObject或JSONArray时收到此错误,我会丢失什么.我添加了 http://sourceforge.net/projects/json-lib/files/将此JSON库添加到构建路径.我有什么想念的吗?
I am trying to learn how to use JSON and writing a simple program however whenever I instantiate a JSON Object it crashes. What am I missing if I receive this error when trying to instantiate a JSONObject or JSONArray. I have added http://sourceforge.net/projects/json-lib/files/ this JSON library to the build path. Is there anything I am missing?
错误消息如下:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at jsonexp.JSONexp.<init>(JSONexp.java:36)
at jsonexp.JSONexp.main(JSONexp.java:55)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException
我了解到,当所使用的库依赖于另一个库时,会发生这种错误.
I have learned that this sort of error occurs when the library being used depends on another library.
我不知道如何处理此问题,非常感谢您的帮助.
I do not know how to deal with this problem and would very much appreciate some help.
谢谢.
推荐答案
一种简单的方法是使用 findjar 为您查找包含缺少类的jar,并将其添加到您的lib文件夹中.
A simple way to do this would be to use findjar to find the jar containing missing class for you and add it to you lib folder.
这篇关于JSONObject等实例崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!