0

When run application from command line I get the following:

Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONException
    at com.poker5o.Main.main(Main.java:39)
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)

The application compiled fine and even when i specify class path to the json jar still get same error.

root@poker5o:/usr/local/poker5o/SignalChannel# ls
com  json-20190722.jar

root@poker5o:/usr/local/poker5o/SignalChannel# java -cp . com.poker5o.Main 
Allocating server socket for the server
Sending parameters to DoListen
Back from DoListen
Setting up read/write buffers
Back from SetBuffers
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONException
    at com.poker5o.Main.main(Main.java:39)
Caused by: java.lang.ClassNotFoundException: org.json.JSONException
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 1 more
Thegremlin
  • 89
  • 7
  • Does this answer your question? [How do I resolve ClassNotFoundException?](https://stackoverflow.com/questions/17408769/how-do-i-resolve-classnotfoundexception) – Amongalen Mar 20 '20 at 10:17
  • Please update the question with command you are using to run. – Smile Mar 20 '20 at 10:21
  • I am specifying the json class path ... same way i specified in compile time... under the com directory i have my poker50/Main class and all the rest of the classes. I read all the questions about NoClassDefdFoundError , but even when i specify the classpath error is still there... – Thegremlin Mar 20 '20 at 10:29

1 Answers1

0

I managed to solve the problem by extracting the json JAR , so now i have:

com & org directories on my working directory. DO i always need to extract jars ?

and do i allways have to place my appliction in same path that represents full name ? com.poker5o.Main...? what if i want to bundle everything like distribute application is there a good way to do so ?

Thegremlin
  • 89
  • 7
  • 1
    You don't need to extract the json JAR. You need to add the jar to your classpath. Eg by using `java -cp .:json-20190722.jar com.poker5o.Main` – Mark Rotteveel Mar 20 '20 at 15:50