I'm working on a project where I've to deliver .jar
file to the user. I'm using Intellij IDEA and as build system I'm using Maven. I've added json-simple
as a dependency.
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
My project works fine while I run from my IDE, but while I try to run my jar file from command line java -jar project.jar
it shows the following error
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException
at utils.PropertiesFile.readProperties(PropertiesFile.java:82)
at utils.PropertiesFile.<init>(PropertiesFile.java:46)
at NewApplication.<clinit>(NewApplication.java:26)
Caused by: java.lang.ClassNotFoundException: org.json.simple.parser.ParseException
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more
I've other dependencies added to my pom.xml
, jar file runs from the terminal without the json-simple dependency. I've found many same types of questions but all saying that json-simple is not added to build path but my problem with only jar file. While other dependencies work fine with the jar file but what problem with this simple-json?
My project structure is here and configuration for building jar