Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Want to cleanly shut down a windowless Java process on Microsoft Windows.

879767Aug 2 2011
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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 30 2011
Added on Aug 2 2011
0 comments
336 views