I have a Java application with a shutdown hook. The shutdown hook is executed when I run the application in IntelliJ and click on the Exit button (as opposed to the Stop button which does not result in the shutdown hook).
I need to be able to shutdown the process from a Windows batch file. I have tried various combinations of the taskkill
command without luck (assuming a PID of 1234):
taskkill /pid 1234 /t
taskkill /pid 1234 /f /t
Is there a way for me to terminate a Java process from an MS batch file, and have the Java shutdown hooks be executed?
The application runs on a Windows server.