I have written a peiece of code that references a JSON library in my Eclipse.
When trying to Export to Jar file, I chose the option Export Java source files and resources.
My code is dependent on JSONObject library.
Now I have packaged all of my files and when I run the jar file on a linux machine, I get the ERROR::
# java -cp SendCommand.jar ExecuteShellComand
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/JSONObject
at ExecuteShellComand.main(ExecuteShellComand.java:19)
Caused by: java.lang.ClassNotFoundException: org.json.simple.JSONObject
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 1 more
Unzipping my jar file yields.
# tree
.
├── commons-io-2.5.jar
├── ExecuteShellComand.class
├── ExecuteShellComand.java
├── json-simple-1.1.jar
├── SendCommand.jar
└── META-INF
└── MANIFEST.MF
1 directory, 6 files
Although all the required files are present, I still get the ERROR. What am I missing here ?