2

When we shutdown windows, sometimes it shows some warnings such that "Application x prevents shutdown"

I am currently developing a java exe application with javafx. How can I make my java program to prevent shutdown like that?

yck
  • 33
  • 4
  • 2
    Does this answer your question? [Java Stop Windows Shutdown](https://stackoverflow.com/questions/61017025/java-stop-windows-shutdown) – Turamarth Jun 17 '22 at 11:56
  • @Turamarth I tried to catch WM_QUERYENDSESSION message with suggested way but most of the time my program directly shuts down without catching that message, so that did not help me – yck Jun 17 '22 at 12:35
  • 1
    [That’s how you do it with AWT](https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/java/awt/Desktop.html#setQuitHandler(java.awt.desktop.QuitHandler)) But you may not want to mix JavaFX with AWT… – Holger Jun 17 '22 at 13:10
  • hope this can help you https://www.codeproject.com/Tips/1257858/How-to-get-shutdown-event-in-windows-from-java-app – Oussama ZAGHDOUD Jun 17 '22 at 15:40

0 Answers0