[英]Java and Tomcat org.json java.lang.ClassNotFoundException
I'm new to servlets, I got java.lang.ClassNotFoundException
whenever I try to include JSON library, I search the web and stackoverflow the only suggestion I found is to install dependencies I've Tried org.json , net.sf.json each with its dependencies nothing works and gives the same exception. 我是servlet的新手,每当尝试包含JSON库时,我都会遇到
java.lang.ClassNotFoundException
,我在网上搜索和stackoverflow,我发现的唯一建议就是安装依赖项我尝试过org.json,net.sf.json每个都依赖于它的依赖项没有任何作用,并且给出了相同的例外。
Any idea? 任何想法?
JSONObject
is contained in java-json.jar
. JSONObject
包含在java-json.jar
。 Make sure that have you have java-json.jar
in your classpath. 确保您的类路径中有
java-json.jar
。 There are multiple places to put jars in tomcat depending which class loader you want the class to load. 有多个位置可以将jar放入tomcat中,具体取决于您要加载类的类加载器。
If this jar is only required by your application then simply put it under your application directory in 如果您的应用程序仅需要此jar,则只需将其放在以下目录中的应用程序目录下
WEB-INF/lib
It is worth reading how classes are loaded in Tomcat to place your jars optimally: http://tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html 值得一读的是如何在Tomcat中加载类以最佳地放置您的jar: http : //tomcat.apache.org/tomcat-7.0-doc/class-loader-howto.html
尝试将Web应用程序的库放在目录中
WebContent/WEB-INF/lib
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.