Java: logo removal or shutdown on Windows and Linux

Is there a way for a Java GUI application to respond to shutdown or logout events other than using JNI? (On Windows, JNI will use WM_QUERYENDSESSION, on Linux?)

The method should allow the program to ask users to save, etc., and then continue the process of logging out.

+5
source share
4 answers

As far as I know, in Java there is no way to catch system shutdown or logout events.

You can, however, catch when the JVM completes by adding closure to completion .

AWT WindowAdapter windowClosing, , . ; , SWT . , , !

, MS Windows . , SIGTERM Linux/UNIX , Linux SIGKILL , .

+4

, Runtime.getRuntime(). addShutdownHook .

+1

, .

GUI Unix , - . , . .

, . , , , .

0

All Articles