java - Cannot add json jar file and run through command prompt? -


i have added json.jar(class file,json.jar,java file in same folder) , compile java program using
javac -cp json.jar j.java
compiles without error.
program.

import org.json.jsonobject; import org.json.jsonexception; class j {    public static void main(string args[]) throws jsonexception {       jsonobject obj = new jsonobject();       obj.put("name", "foo");       system.out.print(obj);    } } 

then try run using
java -cp . j
, following error.

error: jni error has occurred, please check installation , try again  exception in thread "main" java.lang.noclassdeffounderror: org/json/jsonexception             @ java.lang.class.getdeclaredmethods0(native method)             @ java.lang.class.privategetdeclaredmethods(unknown source)             @ java.lang.class.privategetmethodrecursive(unknown source)             @ java.lang.class.getmethod0(unknown source)             @ java.lang.class.getmethod(unknown source)             @ sun.launcher.launcherhelper.validatemainclass(unknown source)             @ sun.launcher.launcherhelper.checkandloadmain(unknown source)     caused by: java.lang.classnotfoundexception: org.json.jsonexception             @ java.net.urlclassloader.findclass(unknown source)             @ java.lang.classloader.loadclass(unknown source)             @ sun.misc.launcher$appclassloader.loadclass(unknown source)             @ java.lang.classloader.loadclass(unknown source) 

use java -cp "json.jar;" j instead of java -cp . j
add jar file in order run too.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -