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.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With