Getting error when importing json jar in my java file in linux -
this java code
import org.json.jsonarray; import org.json.jsonexception; import org.json.jsonobject; public class plutomake { public static void main(string[] args) throws jsonexception { } }
and compile , compiles without error
javac plutomake.java -cp java-json.jar
now copied project eclipse windows, , using jar worked fine. access json functions. here on linux, when run it, get
exception in thread "main" java.lang.noclassdeffounderror: org/json/jsonexception caused by: java.lang.classnotfoundexception: org.json.jsonexception @ java.net.urlclassloader$1.run(urlclassloader.java:217) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:205) @ java.lang.classloader.loadclass(classloader.java:323) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:294) @ java.lang.classloader.loadclass(classloader.java:268)
if remove throws jsonexception
can run it. reason can import jar can't access of functions/exceptions without crashing program...
jar file answer link importing json eclipse project
does know how fix this?
thanks
add jar file runtime classpath
java -cp java-json.jar:. plutomake
Comments
Post a Comment