I had a fully functional Java program that I am now trying to put into a package instead of having it in the default package. All of the .java files are in the mymap
package, and I am trying to run black box tests in my MyMapTest.java
file. The problem is that I don't know how to properly run this in the command line now that I have it in a package. I got stuck trying to google for answers.
I can get it to compile:
javac -cp "../junit.jar" *.java;
But when I try to run it as I previously had...
java -cp .:../junit.jar org.junit.runner.JUnitCore MyMapTest
I get the error java.lang.NoClassDefFoundError: mymap/MyMap
for all of my tests. I guess the issue is that somehow I am not properly including mymap, perhaps in the classpath?
Similarly, I also have white box tests in MyMapWhiteBoxTest.java
, where this file is also in the mymap
package. I cannot figure out how to properly run these tests either. Trying to run it the same way, I get:
Exception in thread "main" java.lang.NoClassDefFoundError: MyMapWhiteBoxTest (wrong name: mymap/MyMapWhiteBoxTest)
For both cases, I have tried mymap/FILE
or somehow also including the package in the classpath, but I'm definitely missing something.