Created a sample program for this, Thanx - gustafc
public class UncaughtException { public static void main(String[] args) { Thread.setDefaultUncaughtExceptionHandler( new Thread.UncaughtExceptionHandler(){ public void uncaughtException(Thread t, Throwable e) { System.out.println("*****Yeah, Caught the Exception*****"); e.printStackTrace();
Exit
***** Yes, caught the Exception ***** java.lang.ArithmeticException: / by zero in thread.UncaughtException.main (UncaughtException.java:12)
source share