How do I get my Java application to shutdown nicely in windows? -


i have java application want shutdown 'nicely' when user selects start->shutdown. i've tried using jvm shutdown listeners via runtime.addshutdownhook(...) doesn't work can't use ui elements it.

i've tried using exit handler on main application ui window has no way pause or halt shutdown far can tell. how can handle shutdown nicely?

the mentioned jni approach work.

you can use jna wrapper around jni make easier use. added bonus (in opinion @ least) faster , more maintainable raw jni. can find jna @ https://jna.dev.java.net/

if you're starting application in start menu because you're trying make behave service in windows, can use java service wrapper found here: http://wrapper.tanukisoftware.org/doc/english/download.jsp


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -