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
Post a Comment