Netbeans: How do I break on a NullPointerException?

11,539

Go to debug > New Breakpoint (alternatively CTRL+SHIFT+F8). Change the breakpoint type to Exception in the top right hand drop down menu. Type java.lang.NullPointerException in the Exception class field. Choose whether to break on caught, uncaught or both.

Debug your code and watch the glorious auto breakpoint when the Exception is thrown.

Share:
11,539
D.C.
Author by

D.C.

Updated on June 14, 2022

Comments

  • D.C.
    D.C. about 2 years

    When debugging a java program in netbeans, I want the debugger to stop on the line that causes a NullPointerException so I can examine the variables there. I believe I have to use a condition on the breakpoint set at that line, but what is the syntax of the condition?

    thanks for the help

  • Mark Jeronimus
    Mark Jeronimus over 10 years
    I did that and it's simply not stopping, like the breakpoint is not even there. Using netbeans 7.0.1. and ArrayIndexOutOfBoundsException Help.
  • Hatoru Hansou
    Hatoru Hansou over 8 years
    Note that at the bottom of the New Breakpoint Dialog there is a field to stop the current thread or all application threads, also you can make "All threads" the default value, in my case that was the most useful.