Why am I getting an IllegalThreadStateException error in ProcessBuilder --Java?

Viewed 441

This code results in an IllegalThreadStateException runtime error from the line with the if statement:

public static void main(String args[]) throws IOException, InterruptedException {
    Runtime runtime = Runtime.getRuntime();
    Process proc = new ProcessBuilder("\"c:\\[directory]/doer.exe\"").start();
    if(proc.exitValue() == 1)
        System.out.println("Output: 1");
}

the executable this is supposed to run specifically has the exit code 1. What am I doing wrong and how can I fix it?

1 Answers
Related