Adding a Watch
Local Variables Window
Stopping the Debugger
NetBeans IDE provide a debugging tool that will allow to trace the execution of your programs you can debug by setting breakpoints, watches in your code and run your application in the debugger. Using the debugger tool you can execute your program line by line and examine the value within your application to locate logical errors in your java programs.
A breakpoint is a mark in the source code that indicates the debugger to stop when the execution reach it. When your program stops on a breakpoint, you can inspect the current values of the variables in your program or continue the execution of your program, one line at a time. To set a breakpoint, click on the left margin (in grey) on the line where you want to place the breakpoint. NetBeans highlights the line in red with a red mark on the left margin.
To remove a breakpoint, click on the breakpoint mark on the left, it will toggle the breakpoint off.
The New Watch window pop up, click OK to add the variable to the Watch list.
The Watches window displays the list of current watches, their type and values.
If the Watch window is not visible, choose Debugging>Watches in the Windows menu .
To remove a watch from the list, right click on the watch you want to remove and select Delete.
There are several ways to start the execution of your java program in debug mode.
Once the execution of your program has stopped, you can trace the execution of your program using the following options:
Step Over ( ) - Executes one line of code. If the line is a call to a method, executes the method without stepping into the method's code.
Step Into ( )- Executes one line of code. If the line is a call to a method, step into the method and stop on the first line of the method.
Step Out () - Executes one line of code. However, if the source code line is in a method, it will execute the remaining source code in the method and returns to the caller of the method.
Run to Cursor () - Executes the program to the line where the cursor is located.
- Continue the execution of program until the next breakpoint or until the
4. Local Variables Window
The local variables displays the name, data type and values of all the values in the current scope as well as static member variables among others. To activate the Local Variables window, select Debugging > Local Variables in the Windows menu. The debugger allows you to change the value of a variable in the Local Variable window and then continue the execution of your program using that new variable's value.
5. Stopping the Debugger