JSONObject etc.

I am trying to learn how to use JSON and write a simple program, however whenever I create an instance of a JSON object it fails. What am I missing if I get this error when trying to create an instance of JSONObject or JSONArray. I added http://sourceforge.net/projects/json-lib/files/ this JSON library to the build path. Is there something I can't see?

The error message is as follows:

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 found out that such an error occurs when the library used depends on another library.

I do not know how to deal with this problem, and I really appreciate the help.

Thanks.

+1
source share
3 answers

An easy way to do this would be to use findjar to find the jar containing the missing class for you and add the lib folder to it.

+1
source

Yes, the bank in which you include has its own runtime dependencies that are not executed.

java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException

When you see these type errors, I usually google until I find the library responsible. In this particular case, this is Apache Commons Lang . Inclusion of this jar in the path of your class should solve the problem

0
source

You forget the jar containing the NestableRuntimeException class.

Based on the package of this exception, this is Apache Commons , and you should upgrade to Apache Commons and download the Apache Commons Lang library. Download the commons-lang-xy-bin archive . (Tar.gz | bin) , get the jar from the archive and add it to your project or java classpath.

0
source

All Articles