I packed test classes into JAR. I have junit-4.10.jar
and aJar.jar
in the same folder. When I try to execute:
java -cp .:junit-4.10.jar org.junit.runner.JUnitCore TestOne
Error: Could not find or load main class org.junit.runner.JUnitCore
How to make it work?
When I type: java aJar.jar:junit-4.10.jar org.junit.runner.JUnitCore TestOne
I am getting
Error: Could not find or load main class aJar.jar:junit-4.10.jar
You seem to be running under Windows, not LINUX/UNIX. The path separator on Windows is ;
, not :
. Additionally, you haven't put you jar file in the classpath. So what you want is:
java -cp aJar.jar;junit-4.10.jar org.junit.runner.JUnitCore TestOne
This of course assumes that both jars are in the current directory. You should also always avoid putting classes in the default package.
I had recently the same problem (JUnit 4.12) and I managed to solve it (Windows) by the following command:
java -cp "<libs>;<relative path to .class project folder>" org.junit.runner.JUnitCore <package.ClassName>
Import to notice the "" in the classpath declaration and separated by ";"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.