I have Cobertura instrumented jar running in JVM. When I press Ctrl-C in Windows console, where application runs, JVM ends and Cobertura results are successfully flushed to cobertura.ser file. But I need stop this JVM with command/tool (not Ctrl-C), something like "soft kill" in Linux ("kill" command without "-9" parameter). When I use "taskkill /PID 1234", it writes:
D:\>taskkill /PID 1234
ERROR: The process with PID 1234 could not be terminated.
Reason: This process can only be terminated forcefully (with /F option).
But when I use parameter /F, JVM is terminated forcibly and that is why Cobertura results are not flushed to cobertura.ser file.
How to kill JVM using Windows command/third party tool with successful Cobertura flush (windows "soft kill")?