Close jar programmatically

2

I currently have a (main) JAVA program, which calls it another JAVA program (child) ... this is Ok .. however when I close the main program, I also close the child program.

I've tried:

Runtime.getRuntime().exec("taskkill /F /PID **NOMEDOPROGRAMA**");

But it did not work ...

    
asked by anonymous 13.02.2014 / 18:40

1 answer

4

When you create the process with the exec() method, an instance of Process . Then you can save this reference and later destroy it with the destroy() .

Example:

Process p = Runtime.getRuntime().exec("**NOMEDOPROGRAMA**");
...
p.destroy();
    
13.02.2014 / 18:48