Java ClassNotFoundException: org.json.JSONException

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18991633/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 13:08:31  来源:igfitidea点击:

ClassNotFoundException: org.json.JSONException

javajson

提问by Narayana Nagireddi

I get the below exception even after having json.jar and commons-collections.jar in classpath. It fails exactly at the import statement for JSONException

即使在类路径中有 json.jar 和 commons-collections.jar 之后,我也会收到以下异常。它在导入语句中完全失败JSONException

Caused by: java.lang.ClassNotFoundException: org.json.JSONException
at java.net.URLClassLoader.findClass(URLClassLoader.java:434)
at com.ibm.ws.bootstrap.ExtClassLoader.findClass(ExtClassLoader.java:191)
at java.lang.ClassLoader.loadClass(ClassLoader.java:660)
at com.ibm.ws.bootstrap.ExtClassLoader.loadClass(ExtClassLoader.java:111)
at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:62)
at com.ibm.ws.classloader.ProtectionClassLoader.loadClass(ProtectionClassLoader.java:58)
at com.ibm.ws.classloader.CompoundClassLoader.loadClass(CompoundClassLoader.java:509)
at java.lang.ClassLoader.loadClass(ClassLoader.java:626)
... 30 more

回答by Herms

That looks like a runtime error, not a compile error, so the build path probably doesn't help you. Do you have those jars in your classpath? That's what's used at runtime to find classes.

这看起来像是运行时错误,而不是编译错误,因此构建路径可能对您没有帮助。你的类路径中有那些罐子吗?这就是在运行时用于查找类的内容。

回答by szedjani

Put your JAR libraries into the WEB-INF/lib folder.

将您的 JAR 库放入 WEB-INF/lib 文件夹中。