Could not find class Java JUnit

2019-07-18 02:46发布

问题:

I'm begginer in Java. Can you help me to find error? I run this using command line in Windows from the root folder of project.

java -classpath lib/junit.jar;classes/ua/edu/sumdu/j2se/savchenko/pr2/Task.class
org.junit.runner.JUnitCore ua.edu.sumdu.j2se.savchenko.pr2.tests.TaskTest

My files location:

classes/ua/edu/sumdu/j2se/savchenko/pr2/Task.class
classes/ua/edu/sumdu/j2se/savchenko/pr2/tests/TaskTest.class
lib/junit.jar

回答1:

java -classpath lib/junit.jar;classes 
org.junit.runner.JUnitCore ua.edu.sumdu.j2se.savchenko.pr2.tests.TaskTest


回答2:

Your class path should only include the root of the class hierarchy, not the complete path to a class.

Also, it's important to include what the exact error is when asking questions, otherwise we're usually guessing.