Header Ads Widget

Responsive Advertisement

Ticker

6/recent/ticker-posts

Java source code to determine when application exit by print a line of text on command prompt (Java)

*************************************************************
COMPLETE SOURCE CODE FOR : DetermineWhenApplicationExit.java
*************************************************************
public class DetermineWhenApplicationExit
{
public static void main(String[]args)
{
 Runtime.getRuntime().addShutdownHook(new Thread()
 {
  public void run()
  {
   //Application will print "BYE" when it close
   System.out.println("BYE");
  }
 });

 //Make this application terminate
 System.exit(0);
}
}


*************************************************************
JUST COMPILE AND EXECUTE IT
*************************************************************