I am trying to execute an external program (.exe) out of a java file. This is my code so far:
try{
Process process = new ProcessBuilder(path).start();
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}
}
catch(Exception e){e.printStackTrace();}
The initial output of the program is displayed on the console window of my java program but unfortunately it requires a user password and hitting enter. I already tried to implement a lot of possible solutions I found on the internet like .inheritIO() or forwarding the commands within process-arguments i.e. Process process = new ProcessBuilder(path,"pw","/c").start(); but that doesn't work. I don't understand why the input stream works perfectly fine, but any kind of output stream does not seem to work.