-2

I have a batch file that contains kill command to stop execution of my application but I just want my application to run the ShutdownHandler before stopping execution.

Same happens in my application when use ctrl+c.

set /p evt=< bin/evtPid.txt
set /p jvt=< bin/jvtPid.txt
taskkill /pid %evt% 
taskkill /pid %jvt%
Anukul
  • 55
  • 1
  • 8

1 Answers1

0

Normally Java does start the shutdown handler if you Ctrl+C it, but that’s not very clean or reliable. This should happen for taskkill, too as long as you do. ot use the /force option. (it might not work if there is no console windows, if sou have some service launcher).

So most Java servers implement some form of shutdown mechanism (for example tomcat has a dedicated shutdown socket and JBoss implements a shutdown command over its remoting socket.)

eckes
  • 10,103
  • 1
  • 59
  • 71