I forked one project from github and when i want to run it gives error. I added org.json
jar file to jdk\lib
and also set the Path variable to it. I compiled code but it got no errors but when i run it i get exception as follows : (and I am running it using command prompt)
Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONExceptio n at java.lang.Class.getDeclaredMethods0(Native Method) at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.privateGetMethodRecursive(Unknown Source) at java.lang.Class.getMethod0(Unknown Source) at java.lang.Class.getMethod(Unknown Source) at sun.launcher.LauncherHelper.validateMainClass(Unknown Source) at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source) Caused by: java.lang.ClassNotFoundException: org.json.JSONException at java.net.URLClassLoader.findClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source) at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source) at java.lang.ClassLoader.loadClass(Unknown Source)... 7 more
Add required jar to classpath like this:
For *nix-like systems:
export CLASSPATH=<path-to-app>/myapp.jar:<path-to-app>/lib/json.jar:.
java MyApp
For Windows:
set CLASSPATH=<path-to-app>/myapp.jar;<path-to-app>/lib/json.jar;.
java MyApp
...or via manifest:
Manifest-Version: 1.0
Main-Class: MyApp
Class-Path: /lib/json.jar