1

Is there any easy to follow tutorial for debugging Java / J2EE applications in eclipse? A step by step guide on how to check for unchecked and checked exceptions? I have been trying to find on the internet, but to no use.

1
  • You can use conditional breakpoints to hunt down certain exceptions - but I don't know of any documentation... Commented Oct 1, 2010 at 7:11

2 Answers 2

1

To add a Java Exception Breakpoint: Select the "Breakpoints" view in the Debug perspective and click on the view toolbar button for exception breakpoints (or choose Run->Add Java Exception Brekakpoint). In the next dialog, type the name of the exception (camel case is support, simply type NPE if you want to catch NullPointerExceptions, you'll get a list matching items), select it from the list and press OK. C'est ca.

You can activate/deactivate this special breakpoint from the Breakpoints view like normal breakpoints.

More fun: right click on a breakpoint entry in the Breakpoints view and choose "Breakpoint Properties". There you can add extra conditions, like 'only break when myCustomString.equals("WTF")' or something else. But conditional breakpoints will slow down the application significantly, only activate them if you really need them.

Sign up to request clarification or add additional context in comments.

Comments

1

The debugger in Eclipse will automatically suspend execution (and let you inspect variables/step/resume etc) if an uncaught exception is thrown.

Enter for instance the following program...

public class Test {

    public void methodA() {
        methodB("hello");
        methodB(null);
    }

    public void methodB(String s) {
        System.out.println(s.substring(2));
    }

    public static void main(String[] args) {
        new Test().methodA();
    }
}

... and click the little "bug"-icon or choose Run -> Debug As -> Java Application

enter image description here


A few useful tutorials

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.