Using JavaFX, I am trying to run a program a.out on Terminal of Mac OSX. The following code does not work on Mac. The same code works on Windows by writing cmndM={"cmd","/c","start","a.exe"}. What's wrong on Mac?
protected void onRunClick(ActionEvent evt) throws IOException {
String exeM="./a.out";
Runtime runtime=Runtime.getRuntime();
String[] cmndM= {"/bin/sh","-c",exeM}; Process pm=null; File dirM=new File(pth);
try {
pm=runtime.exec(cmndM, null, dirM);}
}catch (IOException e) {
msg.setText("Error in running simulation.");
}
}
It might be related to location of the file.
I'd have tried with fixed location first, just to be sure it works.
Also, make sure the file is actually there, inside
pth.