简体   繁体   English

尽管jar在类路径中,但获取ClassNotFoundException

[英]Getting ClassNotFoundException though jar is in classpath

I running a Java application on an Amazon EC2 instance which is a linux server. 我在作为Linux服务器的Amazon EC2实例上运行Java应用程序。 I included a json jar in the build path and I checked the class path and it's there. 我在构建路径中包含一个json jar,并检查了类路径,它就在那里。 When I import the class 当我导入课程时

import org.json.*;

I dont get any compilation errors, but when I execute my app I get the ClassNotFoundException. 我没有得到任何编译错误,但是当我执行我的应用程序时,我得到了ClassNotFoundException。

Exception in thread "Thread-1" java.lang.NoClassDefFoundError: org/json/JSONException
    at Group.run(Group.java:62)
    at java.lang.Thread.run(Thread.java:744)
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

Does anybody know how to fix it? 有人知道如何解决吗?

使用Java反编译器工具并检查jar中是否存在class json异常,或者是否包含必要的jar。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在类路径中的分布式缓存罐,但得到ClassNotFoundException - Distributed Cache Jar in classpath but getting ClassNotFoundException ClassNotFoundException,即使包含该类的jar正确存在于类路径中 - ClassNotFoundException even though the jar containing the class is properly present in the classpath 替换classpath中的jar后出现ClassNotFoundException - ClassNotFoundException after replacing a jar in classpath 即使我有正确的jar,也要获取ClassNotFoundException - Getting a ClassNotFoundException even though I have the correct jar 异常:java.lang.ClassNotFoundException: javax.activation.DataHandler 即使 javax.mail.jar 在类路径下? - Exception: java.lang.ClassNotFoundException: javax.activation.DataHandler even though javax.mail.jar is under classpath? 获取java.lang.ClassNotFoundException,即使我已经使用-cp指定了正确的jar - Getting a java.lang.ClassNotFoundException even though i've specified the correct jar with -cp 我收到“java.lang.ClassNotFoundException: com.google.gson.Gson”错误,即使它是在我的类路径中定义的 - I am getting “java.lang.ClassNotFoundException: com.google.gson.Gson” error even though it is defined in my classpath NoClassDefFoundError 即使 Jar 存在于类路径中 - NoClassDefFoundError even though Jar is present in classpath classpath缺少jar文件,即使指定了 - classpath missing jar file even though specified ClassNotFoundException,即使包含JAR是构建的一部分 - ClassNotFoundException, even though the containing JAR is part of the build
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM