I'm working on a chess program in Java. To calculate the best move (when a person plays against the computer) I use a UCI (universal chess interface). That's a Terminal application (I'm using Mac OS X). With Java I want to execute some commands to get the best move. That's what I have up to now:
String[] commands = {"/Users/dejoridavid/Desktop/stockfish-6-64", "isready", "uci"};
Process process = null;
try {
process = Runtime.getRuntime().exec(commands);
} catch (IOException e) {
e.printStackTrace();
}
BufferedReader stdInput = new BufferedReader(new InputStreamReader(process.getInputStream()));
// read the output from the command
String s;
try {
while ((s = stdInput.readLine()) != null) {
System.out.println(s);
}
} catch (IOException e) {
e.printStackTrace();
}
The first command in the array calls the terminal application. The second and third one are both in-app-commands. Now I have one problem. Only the first two commands are executed, their result is printed in the console, the third command is ignored. Did I do something wrong? Please tell me how to also execute the third (or more, 4th, 5th, etc) command.