When debugging, you can use breakpoints to specify a line of code at which the debugging should stop execution. With execution stopped at a breakpoint, you can inspect variable values in the Locals window, check scenarios by trying out new values in the Watch window, and so on.
You can set a breakpoint in your code to halt execution on that line, immediately before it is executed. You can then examine variable values and/or the call stack or set other breakpoints.
To set or remove a breakpoint, go to Source View and put the cursor on the line on which you want to break. Click the Toggle Breakpoint button on the toolbar. You can also toggle a breakpoint by pressing F9, by clicking in the gray edge to the left of the line numbers in Source View, or by right-clicking on the line of source code and selecting Toggle Breakpoint from the context menu that appears.
You can also set breakpoints that are triggered when exceptions occur. To set an exception breakpoint, select Debug-->Create Breakpoint, in the Create Breakpoint dialog, select the Exception radio button, and provide the fully qualified classname of the exception. The debugger will hit the breakpoint whenever an exception of that class or one of its subclasses is thrown. You can determine whether the breakpoint always needs to be hit when an exception occurs, or whether the breakpoint only needs to be hit when the exception is either caught or not caught. Exception breakpoints are not set for a specific line of code, so your code in not marked with a red circle and highlighting when you create one.
Method breakpoints allow you to set a breakpoint that will be hit as soon as a particular method is called. To create a method breakpoint, select Debug-->Create Breakpoint. In the Create Breakpoint dialog, select the Method radio button. Enter the fully qualified class name that contains the method, and the method's name. If the method is overloaded, you may also include the argument list for the specific version on which you'd like to set a breakpoint. If the method is overloaded and you do not specify the argument list, method breakpoints will be set in all of the overloaded versions.
When debugging JSP files, you can also right-click on a tag library tag in the source editor and choose Taglib Breakpoints from the context menu. This brings up a dialog that shows the implementing class for the taglib and allows you to set breakpoints on all of the taglib methods it implements.
Additionally, when setting breakpoints in a JSP file, the breakpoint icon will have a black X over it if the line is not a valid line for a breakpoint. You can still set the breakpoint, but you will not hit it when running the JSP. This feature is not available for other file types.
To clear all breakpoints at once including exception breakpoints in the project, click the Clear All Breakpoints button on the toolbar, or press Ctrl-F9.
You can also disable breakpoints, which prevents the debugger from stopping at them, but doesn't delete them, so that they're easy to re-enable. To disable all breakpoints, select Disable All Breakpoints from the Debug menu or press Ctrl-Shift-B. To enable all breakpoints, select Enable All Breakpoints from the Debug menu or press Ctrl-B.