5

I'm executing an external program which runs alongside Java using this:

Process p = Runtime.getRuntime().exec("/path/to/binary"); 

When I stop the Java application, the external program continues to run but I want this to stop too.

1

2 Answers 2

4

To trigger the shutdown, you could add a shutdown hook to your Java application. See Runtime.addShutdownHook().

To effect the shutdown, you could either communicate to the external process a request to stop gracefully, or call Process.destroy()

Sign up to request clarification or add additional context in comments.

Comments

1

use shutdown hook : http://download.oracle.com/javase/1.4.2/docs/guide/lang/hook-design.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.