I am running some java apps and I need to shutdown/close all apps gracefully from windows bat script.
So my question is:
How to invoke shutdown hook by windows bat script and gracefully shutdown java program.
Any suggestion is appreciated. Thanks in advance.
A "graceful" shutdown in Java is generally achieved by letting all non-daemon threads complete their work normally. If you have your app listen for a "shutdown" command on some port, then you could have the script trigger the command to that port, which you could then use to set appropriate flags for your threads to stop working, letting the JVM shut down. That's probably the simplest way I've seen it done.