in a project I need to execute a java application from another java application. So far so good. Now I am stuck at the point, where the former needs to fetch the latters logs from the console.
The execution of the second is handled by the following snipped of code:
ArrayList<String> commands = new ArrayList<>();
commands.add("javaw");
commands.addAll(data.returnPropertiesAsPrefixedStringList());
commands.add("-cp");
commands.add(data.getClasspathJar().toString());
commands.add("[PathToMainClass]");
//data.getArgs for example contains the path to the second java (jnlp) file
commands.addAll(data.getArgs());
ProcessBuilder java = new ProcessBuilder().inheritIO().command(commands);
Process start = java.start();
How can I now fetch the logs "start" writes to the console? As I did not quite know what I had to search for, I did not manage to find fitting answers.
Edit:
I have tried getting the logs like that, but it did not work. The Logs weren't recognised at all.
Process start = java.start();
BufferedReader input = new BufferedReader(new InputStreamReader(start.getInputStream()));
String line;
while ((line = input.readLine()) != null) {
System.out.println("It Did Work: " + line);
}
Thank you in advance for your help.
-IHaveNoClue