0

I have a testing application running as expected when executed on Eclipse IDE. We want to export it to a jar and execute it via command line.

After executing, and running the application with the following comand, i encounter an error

java -jar testclient.jar -info
Error: Unable to initialize main class testclient.Main
Caused by: java.lang.NoClassDefFoundError: org/junit/runners/model/InitializationError

( -info) is an argument for the main method in the class. Manifest file is pointing to the correct class.

On research of this topic, i checked whether the required libraries are added to the path. They are correctly added.

Could anyone provide some guidance

  • What's your classpath? – tgdavies Jul 21 '21 at 13:10
  • I am currently running the command line, in the project directory. I cannot use the java -cp . -jar "testclient.jar". Just came across a way to export the jar to the directory itself and use java -cp testclient.jar:lib/* – Rakshan Premsagar Kapikad Jul 21 '21 at 13:34
  • What makes you think that the required libraries are on the classpath? – tgdavies Jul 21 '21 at 13:36
  • Yes I could be wrong here. I think you could elaborate a bit better. Just a beginner here – Rakshan Premsagar Kapikad Jul 21 '21 at 13:38
  • I believe that there is an inner error that is causing this, the program is trying to throw an InitializationError but that class isn't found. That error can be caused by e.g. methods not being public but is hard to guess. – nordenvall Jul 21 '21 at 13:40
  • @nordenvall, thank you for the suggestion. Is it possible that an application running smoothly on IDE, fails on the command line? I mean, I am totally a newbie here with an expectation to witness the same results.. – Rakshan Premsagar Kapikad Jul 21 '21 at 13:42
  • See https://stackoverflow.com/questions/34413/why-am-i-getting-a-noclassdeffounderror-in-java – tgdavies Jul 21 '21 at 13:47
  • I think you should run your program under the debugger and see exactly what's happening. I still suspect a classpath problem, but perhaps there's an exception being ignored too. – tgdavies Jul 21 '21 at 13:48
  • @tgdavies thank you.. Also, i tried another method wherein, i go to the bin folder, and run the command java -cp . testclient.Main Result is the same error – Rakshan Premsagar Kapikad Jul 21 '21 at 14:14

0 Answers0