I have a swing java project, call it "A", and I have another not-swing, only backend project, which has no frames and panels, only run in background, and prints texts to command line with System.out.println, call it "B".
What I want is:
- start "B" from "A"
- monitor "B" in "A": if "B" prints something to the command line with System.out.println, it should be visible in a TextArea of "A"
- if "B" is finished, "A" should know about it
I already know that I can start the jar from another jar by these lines:
Process ps=Runtime.getRuntime().exec(new String[]{"java","-jar","A.jar"});
ps.waitFor();
or:
Process proc = new ProcessBuilder("java", "-XMx512M", "-jar", "MainJar.jar").start();
int result = proc.waitFor();
But how to monitor the started jar? Can anyone help me with an easy example? Thank you!