Search code examples
javabrowsercross-browserjava-web-startbrowser-detection

Java Web start - how to detect when app is closed?


How do you detect when an App is open or closed?

  1. User clicks on link/button.
  2. Web Browser launches Java desktop app via Java Web Start.

At this point how do you have the browser detect if the App is able to launch or unable to launch, if the app has launched and closed by the user?


Solution

  • Do you registered the class containing windowClosing() method via addWindowListener()?

    Java explicitly allows you to close process, please check below code:

    Runtime.getRuntime().addShutdownHook(new Thread() {
    
        @Override
        public void run() {
            // you can write your code here
        }
    });