Using the Watches Window

A watch enables you to monitor the changing values of variables or expressions as your program runs. After you enter a watch expression, the Watch window displays the current value of the expression. As your program runs, the value of the watch changes as your program updates the values of the variables in the watch expression.

A watch evaluates an expression according to the current context which is controlled by the selection in the Stack window. If you move to a new context, the expression is re-evaluated for the new context. If the execution point moves to a location where any of the variables in the watch expression are undefined, the entire watch expression becomes undefined. If the execution point returns to a location where the watch expression can be evaluated, the Watches window again displays the value of the watch expression.

Create instance breakpoints from the context menu.

Note: For more information about this window including its context menu options, press F1 or click Help in the Watches window.

To open the Watches window:

  1. Open source files in the Source Editor and set breakpoints.

  2. Click debug_icon Debug from the toolbar.

  3. When the debugger pauses at a breakpoint, select View then choose Debug Windowsthen choose Watches from the main menu.
    The Watches window appears.

To change which columns are displayed in the Watches window:

To add a watch:

To watch a static field:

Enter the full name of the class followed by a period (.) and the name of the field. For example:

java.io.File.separator

To watch the current exception while stopped at an exception breakpoint, enter:

_throw.


Related topics

Using the Debugger Windows
Setting Preferences for the Debugger Windows
Examining Program State in Debugger Windows
Using the Stack Window
Setting Expression Watches
Using Acceptable Legal Java Expressions in the Debugger