Want to cleanly shut down a windowless Java process on Microsoft Windows.
Hi All,
As the subject says, I want to cleanly shut down a windowless Java process on Microsoft Windows.
The requirements are:
# I want the process being shut down to be able to register either SignalHandlers or ShutdownHooks and to have them called during process shutdown.
# I don't have any control over the code of the process being shut down, so I can't insist that these processes build with a Jar that I have provided.
# I can do pretty-much anything in the process sending the shut-down request, including native calls (e.g. send WM_CLOSE to Window handles).
# I want to be able to stop both java and javaw processes.
Now, as far as I can see, the JVM doesn't create any Windows, so I cannot use PostMessage to send a WM_CLOSE to them.
Calling the win32 API TerminateProcess doesn't fly, because the application doesn't get the chance to run shutdown hooks.
Any ideas?
Thanks,
Huw