简体   繁体   中英

Getting ClassNotFoundException though jar is in classpath

I running a Java application on an Amazon EC2 instance which is a linux server. I included a json jar in the build path and I checked the class path and it's there. When I import the class

import org.json.*;

I dont get any compilation errors, but when I execute my app I get the 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。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM