Reputation: 177
I cannot understand why this
ioannis@ioannis-GA-MA74GM-S2H:~$ java -cp /opt/junit4.6/junit-4.6.jar org.junit.runner.JUnitCore /opt/CalculatorTest
gives the error:
Could not find class: /opt/CalculatorTest
and this work fine:
ioannis@ioannis-GA-MA74GM-S2H:~$ java -cp /opt/junit4.6/junit-4.6.jar:/opt org.junit.runner.JUnitCore CalculatorTest
JUnit version 4.6
.
Time: 0.005
OK (1 test)
in the first I give the full path for class /opt/CalculatorTest
Upvotes: 0
Views: 144
Reputation: 12266
The classname is intended to be just the class name, not a path. If it is in a package, you can have foo.Bar. If it is in the default package, you can only have Bar.
As you noticed, the classpath is the place to identify the physical directories Java should look in to find the class.
Upvotes: 1