Using process builder in java but I want the program to wait while the process is finished.
I tried to use pb.wait() but it keeps on waiting. How do I wait till all the commands have finished executing?
This is a very small part of my code.
String[] commands = {All my commands go here};
String command = "cmd.exe /c " + String.join(" && ", commands);
ProcessBuilder pb = new ProcessBuilder(command.split(" "));
pb.inheritIO();
try {
pb.start();
try {
pb.wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
} catch (IOException e) {
System.out.println("Error, Could not run.");
e.printStackTrace();
}
}