Master IntelliJ IDEA Debugging: Essential Tips and Tricks
This comprehensive guide walks you through IntelliJ IDEA's debugging features, covering the interface, basic shortcuts, variable inspection, expression evaluation, smart step‑into, conditional breakpoints, multithreaded debugging, frame rollback, request interruption, and JRebel activation for hot‑deployment.
1. Debug Overview
IntelliJ IDEA provides a dedicated Debug mode that displays a toolbar, breakpoint controls, and various panels to monitor program execution. When a breakpoint is hit, the Debug window activates automatically, showing the call stack, variables, watches, and control buttons.
Start the application in Debug mode using the Debug button (separate from the Run button).
Set or remove breakpoints by clicking the gutter or pressing Ctrl+F8.
The Debug window appears automatically at the first breakpoint; it can be forced on via settings.
Eight main toolbar buttons control stepping, resuming, pausing, and other actions.
The service button lets you start/stop the application and manage breakpoints.
The call stack panel lists all method calls for the current thread; you can hide library frames with Show All Frames.
The Variables panel shows local variables at the current breakpoint.
The Watches panel lets you monitor selected variables by dragging them from Variables.
2. Basic Usage & Shortcuts
The main debugging actions correspond to the first two groups of toolbar buttons.
Group 1 (8 buttons):
Show Execution Point ( Alt+F10 ) – jumps to the current execution line.
Step Over ( F8) – executes the current line without entering called methods.
Step Into ( F7) – enters the method on the current line.
Force Step Into ( Alt+Shift+F7) – forces entry into any method, including library code.
Step Out ( Shift+F8) – exits the current method back to the caller.
Drop Frame – rolls back the call stack (explained later).
Run to Cursor ( Alt+F9) – runs execution until the cursor line.
Evaluate Expression ( Alt+F8) – opens a window to compute an expression’s value.
Group 2 (7 buttons):
Rerun – restarts the application after stopping it.
Update Application ( Ctrl+F5) – reloads changed classes and resources.
Resume Program ( F9) – continues execution to the next breakpoint.
Pause Program – pauses the running process (rarely used).
Stop ( Ctrl+F2) – terminates the application; may require killing lingering JVM processes.
View Breakpoints ( Ctrl+Shift+F8) – opens the breakpoint management dialog.
Mute Breakpoints – disables all breakpoints temporarily.
3. Inspecting Variables
During debugging, you can view variable values in several places:
Inline hints next to the code line show the current value.
Hovering over a variable displays its value; clicking opens a detailed view.
The Variables panel lists all locals in the current stack frame.
The Watches panel lets you add custom watches or drag variables from the Variables panel.
4. Evaluating Expressions
The Evaluate Expression dialog (Alt+F8) lets you compute arbitrary expressions, including method calls, without adding print statements. You can also modify variable values directly in this dialog to test different scenarios.
5. Smart Step‑Into
When a line contains multiple method calls, Smart Step Into ( Shift+F7) lists each candidate method, allowing you to choose which one to enter.
6. Conditional Breakpoints
You can attach conditions to breakpoints so they only trigger when a specific expression evaluates to true, reducing unnecessary stops in loops or large data sets.
Right‑click a breakpoint and select Condition , then enter an expression such as exist == true.
In the View Breakpoints dialog you can also enable logging, evaluate expressions on hit, or set hit counts.
7. Multithreaded Debugging
By default, IDEA blocks all threads when one is paused (debug level ALL). You can change this in View Breakpoints → Thread and set it as the default, then switch threads via the Frames dropdown.
8. Rolling Back Frames
IDEA allows you to “drop” the current frame, effectively moving the execution point back to the start of a previous method. This can be done via the Drop Frame button or by right‑clicking a stack frame and selecting Drop Frame. Note that state changes (e.g., modified objects or database updates) are not reverted.
9. Interrupting Debug Sessions
If you need to stop processing after detecting an error, you can use Force Return to return a value immediately, bypassing the remaining code.
10. JRebel Activation (Optional Hot‑Deployment)
JRebel enables hot‑reloading of Java classes and resources without restarting the application. To activate a free, non‑cracked license, you need a Facebook or Twitter account, log in at https://my.jrebel.com/, obtain the activation code, and enter it in the JRebel plugin settings.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Code Ape Tech Column
Former Ant Group P8 engineer, pure technologist, sharing full‑stack Java, job interview and career advice through a column. Site: java-family.cn
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
