Kill JVM not forcibly from command line in Windows 7
Asked Answered
O

1

3

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")?

Oscillation answered 19/2, 2013 at 8:27 Comment(1)
Hi, I am facing the same issue. Did you get any fix for this ?Waterborne
J
0

Try look at WMI, using JavaScript or VBScript you create rules for selecting process and killing it.

For example http://community.spiceworks.com/scripts/show/498-kill-a-process-using-wmi - enlist simple kill script using VBScript

Juniper answered 19/2, 2013 at 8:39 Comment(2)
@RadekJira, well may be let's totally shift a paradigm? Usually Cobertura is applied to unit test. Place to your test java invocation: System.exit - after execution during some time or on some condition.Juniper
You are true, best way is to change paradigm. We have very specific requirements and it will be better to change test-covering technology - for example JaCoCo, which uses on-the-fly instrumentation. Thanks for ideas.Oscillation

© 2022 - 2024 — McMap. All rights reserved.