I am trying to execute a jar file, in terminal.
Jar created in intellij:
Build -> Build Artifacts -> Clean
Build -> Build Artifacts -> Build
Execution cmd:
java -jar helloworld.jar
Error:
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/JSONObject
at main.java.com.example.helloworld.sampleclass.mymethod(sampleclass.java:53)
at main.java.com.example.helloworld.sampleclass.main(sampleclass.java:14)
Caused by: java.lang.ClassNotFoundException: org.json.simple.JSONObject
I have added the following dependency also.
Pom.xml Dependency:
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
The code executes perfectly when I try to run in intellij, but I am getting this error when I run with the jar. Any suggestions would be great.