I'm trying to create an autograder for my Java programming class I'm teaching this semester. The basic idea of the autograder is that it will place a copy of my tester's .class file in same location as the students' turnins (each in their own folder). It will report the results in a text file and give the data back to me.
The issue that I'm stuck on is that I cannot get the ProcessBuilder to execute my tester class, and I've tried various different ways of typing the command out, but I'm not sure what the correct command is. Here is the code:
public...main(String[] args){
///Code not relevant ommitted
Runtime runtime = Runtime.getRuntime();
for (String person : uniqueIds) {
File currentLoc = new File(HW_ID + "/" + person);
ProcessBuilder g = new ProcessBuilder("bash", "-c",
"java", " -cp ", currentLoc.getAbsolutePath(),
" Grader");
Process process = g.start();
process.waitFor();
}
}
"uniqueIds" is a String Array that contains each student's uniqueId, which is the name of the folder that their homework is turned in to. "HW_ID" is a constant that is the name of the folder that the turnin set for all of the students is housed in. So the file structure is: HW_ID/uniqueID/
"Grader" is the name of my program that will grade the turnins. How can I use ProcessBuilder to start my Grader program that is in the specified file location?
EDIT: I'm using a Mac on this, but if the code for Windows is different, please list both. Thanks!