Please suggest if there is any best way around on executing jar from java code then killing parent java code.
a)I have desktop based java application say "Monitor.java" which runs every 5 minutes.
b) How can I START external java application say "execute.jar" from Monitor.java THEN EXIT/KILL Monitor.java
I tried various options using "ProcessBuilder" and calling bat file but I need Monitor (parent application to EXIT, immediately after calling child (execute.jar)
Try1)
ProcessBuilder builder = new ProcessBuilder("java -jar execute.jar");
Process process = builder.start();
---------------
Try2)
Runtime r = Runtime.getRuntime();
Process p = null;
p = r.exec(new String[] { "cmd", "/c", "start C:/temp/Test.bat" });