So i created a project on eclipse, and i want to create a JAR file with it. The project folder contains the following folders:
- src (contains two packages)
- JRE System libraries
- Referenced Libraries ("jasypt-1.9.2.jar" and "json_simple-1.1.jar")
- libs (again: "jasypt-1.9.2.jar" and "json_simple-1.1.jar")
- resources (containing images and files)
If i go to: rclick on Project's name -> Properties -> Java Build Path -> Libraries
I see both libraries correctly added to the Build Path.
Then i go to rclick on Project's name -> export -> JAR file and here i export everything (just to be sure..!). Then i put the MainClass as entry point and then the JAR file is created without any problem.
When i extract the JAR file (registry.jar), i see that it contains everything it needs: [package1, package2, META-INF, libs, resources, .classpath, .project]
Also, the .classpath is correct (at least, seems to me.. not 100% sure!):
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry exported="true" kind="lib" path="libs/jasypt-1.9.2.jar"/>
<classpathentry exported="true" kind="lib" path="libs/json_simple-1.1.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
BUT THEN when i go to execute the registry.jar file from command line (both Windows and Ubuntu), like this:
java -jar registry.jar
i get:
Exception in thread "main" java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException
at ...
at ...
Caused by: java.lang.ClassNotFoundException: org.json.simple.parser.ParseException
at java.net.URLClassLoader$1.run<Unknown Source>
at ...
at ...
... lots more
The program compile and works perfectly inside eclipse. I just can't figure out what's the problem...