I'm attempting to run a file that calls multiple files, but I'm getting some errors.
Inside the current directory called day4Measurement, I have 13 files: BuggyMeasurement.java, BuggyMeasurement01.java, BuggyMeasurement02.java, BuggyMeasurement03.java, BuggyMeasurement04.java...BuggyMeasurement10.java, MeasurementTest.java, and Measurement.java.
Measurement.java contains the main() and calls all the other files.
Here's the main():
public static void main(String [] args){
JUnitCore tester = new JUnitCore();
String s = "Failed to detect: ";
int count = 0;
String [] tests = {"toString prints reverse inches then feet", // 01
"plus modifies this", // 02
"minus modifies this", // 03
"multiple modifies this", // 04
"plus incorrect roll over", // 05
"minus incorrect roll over", // 06
"multiple incorrect roll over", // 07
"plus incorrect non-roll over", // 08
"minus incorrect non-roll over", // 09
"multiple incorrect non-roll over", // 10
"CORRRRECTTT!!!"
};
for (int i = 1; i < tests.length + 1; i++){
testRound = i;
System.out.println("Running: " + tests[i-1]);
TestRunner.run(day4Measurement.MeasurementTest.class);
Result temp = tester.run(day4Measurement.MeasurementTest.class);
if (temp.wasSuccessful()) {
s += tests[i-1] + "; ";
count++;
}
}
System.out.print(10-(count-1)*0.5 + " ");
System.out.println(s);
}
In the Mac Terminal, I run
javac Measurement.java
and I get issues. Here's what I get:
Any suggestions?
Once you have all the files in a directory (they may be in subdirectories - as long as they are all inside some shared directory), let's call it dir, use the following:
Assuming that you are running the command from the same directory that Measurement.java is in. If not, and either way you are safer this way, make it an explicit path to both dir and Measurement.java, such as:
This says to the java compiler "I want to compile Measurement.java, here's where it is, and here's where you can find all the class and/or source files that it needs." It will then compile only the files referred to by Measurement.java, so you don't need to worry about accidentally compiling all of your java files ever.
Compile all the files with javac *.java
One thing to check would be to make sure your directory structure for those files mirrors the package structure. For example, if package for class ABC is com.foo, then your ABC.java file should live in com/foo folder.