java.lang.NoClassDefFoundError: org/json/simple/JSONObject运行



类似的问题已经问过这里关于这个错误,但我已经尝试了大多数的解决方案,仍然得到相同的错误消息。我在我的java应用程序中使用json-simple库。我已经在我的库中包含了json-simple-1.1.1.jar文件。运行Netbeans工作完美。当我尝试通过命令行"java -jar"运行它时,我得到以下错误。即使"java -cp json-simple-1.1.1.jar -jar "也会给出相同的错误。

nullException in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/json/simple/JSONObject
    at gui.keo_synopticx.jb_save_configMouseClicked(keo_synopticx.java:5318)
    at gui.keo_synopticx.access$6000(keo_synopticx.java:49)
    at gui.keo_synopticx$60.mouseClicked(keo_synopticx.java:3358)
    at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
Caused by: java.lang.ClassNotFoundException: org.json.simple.JSONObject
    at java.net.URLClassLoader$1.run(Unknown Source)

我可能错过了json-simple-1.1.1的依赖?任何建议都将非常感激。

/json/simple/jsonobject类肯定在jar文件中。

我能想到的问题的唯一原因是您没有指定jar文件路径,并且jar与您的执行目录不在同一个目录中。

要解决这个问题,你应该在终端上精确设置你的类路径:

syntaxe:

java -classpath <your_archive.jar> [<package>.]<Class_name>

相关内容

  • 没有找到相关文章

最新更新