0

Sorry if I am talking nonsense, I am new to java and java projects.

I have been reading a lot of other peoples questions about the same problem, however even after trying, it doesn't seem to be working for me.

When I run my code in the eclipse ide, the code works perfectly as intended, however after I export it (file -> export -> Java (jar file) and set the main class in the manifest file section -> finish) and run it(outside in my terminal) the error

Unable to initialize main class (my main class)
Caused by java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException

In the build path I have added the external jar in the classpath and selected it in the Order and Export tab, which seemed to be most peoples problem.

I'm also a bit confused to why I am able to load all the other subclasses, such as json.simple.JSONObject and json.simple.parser.JSONParser, but not json.simple.parser.ParseException. (but I guess this could just be the order that they load in?)

I apologize if the answer was easily found somewhere else or is simple.

Thank you for your time if you read this far and any answer would be appreciated a lot.

4
  • What is the command you are using in command line to run the application?
    – Ashish
    Commented Nov 23, 2020 at 13:17
  • Please see the link to similar issue. Check if it is the same in your case. Or, provide the command run from the terminal. stackoverflow.com/questions/16248955/…
    – Ashish
    Commented Nov 23, 2020 at 13:21
  • Thank you for your reply! I am just using the command java -jar myJar.jar when I run it in my terminal. Also, thank you for the link, it helped me understand some stuff, however I think our cases slightly differ because I am trying to make a .jar executable.
    – csl-310
    Commented Nov 23, 2020 at 13:37
  • Yes, You need to link the libraries folder as well i.e. all the dependencies while running the jar command. Here is the link: stackoverflow.com/questions/53025185/…
    – Ashish
    Commented Nov 23, 2020 at 13:42

0

Browse other questions tagged or ask your own question.