title: Java: Handle logoff or shutdown on Windows and Linux
body: <p>Is there a way for a Java GUI application to respond to system shutdown or logoff events, other than to use JNI?  (On Windows, the JNI would use WM_QUERYENDSESSION, on Linux?)</p>
  
  <p>The method should allow the program to prompt users to save, etc., and then continue the logoff process.</p>