Forum Stats

  • 3,852,844 Users
  • 2,264,142 Discussions
  • 7,905,157 Comments

Discussions

Executing jar from java code, then kill parent java code

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 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" });
This discussion has been closed.