You can set a breakpoint on almost any line of code in a source file in the Definitions Pane, using either the "Toggle Breakpoint on Current Line" command in the Debugger menu, the "Toggle Breakpoint" command on the context (right-click) menu in the Definitions Pane, or by pressing Ctrl+B. When a breakpoint is set, the line will be highlighted in red and an entry will appear in the "Breakpoints" panel, which can be displayed using the "Breakpoints" command in the Debugger menu, or by pressing Ctrl+Shift+B. When a method is called in the Interactions Pane and the control flow reaches a line of code where a breakpoint has been set, DrJava suspends the execution of the program, highlights the line in bright blue and prints a message to the Interactions Pane. DrJava then displays a new prompt in the Interactions Pane, allowing you to interact with the suspended program until it is resumed (see Interactions at a Breakpoint). Breakpoints are considered part of a project and are therefore saved to and loaded from a project file.
When setting breakpoints, it is important to remember that only lines with actual executable code can be used. Blank lines and comments will never trigger a breakpoint, even if the line is highlighted in red. (Note that we do not yet support breakpoints on method contracts either, although this will be supported in a later version of DrJava.)
Breakpoints Panel. The "Breakpoints" panel can be displayed using the "Breakpoints" command in the Debugger menu, or by pressing Ctrl+Shift+B. It lists all breakpoints that have been set in the currently open documents, sorted by document and line number. There are several buttons on the right side of the panel that help you manage the breakpoints:
You can select one or more breakpoints and press the "Enable" or "Disable" button to enable or disable the selected breakpoints. When a breakpoint is disabled, it remains set, but the program will not be suspended when the breakpoint is reached. This is useful if you may need the breakpoint again later, but want the program to ignore it right now.
If you select exactly one breakpoint, you can use the "Go to" button to jump to the location associated with the breakpoint.
With the "Remove" button, you can remove one or more breakpoints that you have selected. You may also clear the entire list using the "Remove All" button.
Debugging JUnit Tests. DrJava will also stop at breakpoints during JUnit tests. Simply set a breakpoint on a line of a test method or in a method called by a test, and then choose the "Test Using JUnit" command from the Tools menu. When control flow reaches the breakpoint, the test will be suspended.