Example: Opening the Debugger when an Exception is Thrown (Integrated Debugger)

Copy the following code fragment into the Scrapbook:

try {
  int i = 0;
  int j = 1 / i;
} catch (ArithmeticException e) {
    e.printStackTrace();
}

Select the code fragment and run it by clicking the Run button run.gif (1013 bytes).  The Console window will display the trace.  If this were more than a trivial example, it could be difficult to tell why the exception was thrown.

Now, select Debug > Caught Exceptions from the Window menu.   Enable the check-box for  ArithmeticException.  Select the code fragment and run it again.

Now, the debugger opens when the exception is thrown, showing that the divide-by-zero attempt is the operation throwing the exception.