0

excuse my terms with regards to the build tool, as I am new to this.

I have a Java test application, when I use it on eclipse and run the testcases, everything works smooth. This application also can be built with the ANT tool.

Now, the next approach would be to run the cases from the command line. I clean my project, run the ant build. Build shows successful. I navigate to the bin folder and press

java client.Main

It says an error

Error: Unable to initialize the main class client.Main
Caused by: java.lang.NoClassDefFoundError: org/junit/runners/model/InitializationError

I thought it needs some parameters, and passed some arguments. It fails there as well.

PS: I am a fresher, just working on EX colleague's application here with no documentation.

Also, I have the Junit and hamcrest library already added in the build path

Need some guidance

  • You need to set the class path that the JVM uses to run your application. Perhaps the ant file builds a jar? you might be able to run `java -jar `. – tgdavies Jul 13 '21 at 10:06
  • I have tried that explicitly, exporting as a jar. It fails – Rakshan Premsagar Kapikad Jul 13 '21 at 10:38
  • class path is set. I mean, I can run a simple helloworld program using the command line – Rakshan Premsagar Kapikad Jul 13 '21 at 10:44
  • If you're building with Ant, it won't build in such a way that it will allow you to run with certainty with `java` at the command line. You probably need to run it with Ant, as it will set the classpath *for that app* and other stuff for you. Running `ant -p` should show you if a `run` task is available. – g00se Jul 13 '21 at 11:22
  • I just plainly exported the project as jar, mainfest file was taken care( for the main class), yet it shows an error as above – Rakshan Premsagar Kapikad Jul 13 '21 at 11:50

0 Answers0