由ClassNotFoundException引起的Java JSON Jar NoClassDefFound

时间:2014-09-01 14:31:07

标签: java json eclipse error-handling libraries

我在PHP脚本调用的服务器上打包了一个简单的java文件作为Jar。我有" json-simple-1.1.1"我的java程序中包含的库。但是,当我运行它时,给出了以下错误。我已将json-simple jar添加到我的项目中并导入正确的类。根据我的阅读,它似乎并没有将json-simple库添加到我的清单文件中。有想法该怎么解决这个吗。如果有帮助,我会使用eclipse。

Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException
    at java.lang.Class.getDeclaredMethods0(Native Method)
    at java.lang.Class.privateGetDeclaredMethods(Class.java:2570)
    at java.lang.Class.getMethod0(Class.java:2813)
    at java.lang.Class.getMethod(Class.java:1663)
    at sun.launcher.LauncherHelper.getMainMethod(LauncherHelper.java:494)
    at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:486)
Caused by: java.lang.ClassNotFoundException: org.json.simple.parser.ParseException
    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)

1 个答案:

答案 0 :(得分:1)

您的库可能未被类加载器加载,因此,如果它不在WEB-INF / lib中,请右键单击它并Add to build Path

enter image description here