- Starting a Debugging Session
- Attaching the Debugger to a Running Application
- Starting the Debugger Outside of the Project's Main Class
- Stepping Through Code
- Setting Breakpoints
- Managing Breakpoints
- Customizing Breakpoint Behavior
- Monitoring Variables and Expressions
- Backing Up from a Method to Its Call
- Monitoring and Controlling Execution of Threads
- Fixing Code During a Debugging Session
- Viewing Multiple Debugger Windows Simultaneously
Fixing Code During a Debugging Session
Using the IDE's Apply Code Changes feature (called Fix in NetBeans IDE 4.0), it is possible to fine-tune code in the middle of a debugging session and continue debugging without starting a new debugging session. This can save you a lot of time that would otherwise be spent waiting for sources to be rebuilt and restarting your debugging session.
The Apply Code Changes feature is useful for situations such as when you need to:
- Fine-tune the appearance of a visual component that you have created.
- Change the logic within a method.
Applying code changes does not work if you do any of the following during the debugging session:
- Add or remove methods or fields.
- Change the access modifiers of a class, field, or method.
- Refactor the class hierarchy.
- Change code that has not yet been loaded into the virtual machine.
To use the Apply Code Changes command while debugging:
- When execution is suspended during a debugging session, make whatever code changes are necessary in the Source Editor.
- Choose Run | Apply Code Changes to recompile the file and make the recompiled class available to the debugger.
- Load the fixed code into the debugger.
If you are changing the current method, this is done automatically. The method is automatically "popped" from the call stack, meaning that the program counter returns to the line where the method is called. Then you can run the changed code by stepping back into the method (F7) or stepping over the method (F8).
For a UI element, such as a JDialog component, you can close the component (or the component's container) and then reopen it to load the fixed code in the debugger.
- Repeat steps 1 to 3 as necessary.