30+ IntelliJ IDEA Debugging Tricks to Boost Your Productivity 10×
Mastering IntelliJ IDEA's powerful debugging shortcuts and features—such as execution point navigation, step controls, conditional breakpoints, exception simulation, multithread handling, variable modification, and remote debugging—can dramatically reduce bug‑fixing time and make development up to ten times more efficient.
Writing and fixing bugs occupies most of a programmer's daily work; mastering IntelliJ IDEA's debugging shortcuts can dramatically improve efficiency.
IDEA Debugging Functions
Show Execution Point (Alt+F10) – Returns to the currently active breakpoint when the mouse is not on the breakpoint line.
Step Over (F8) – Executes the next line without entering called methods; the most frequently used step.
Step Into (F7) – Enters the method body; does not step into JDK methods.
Force Step Into (Alt+Shift+F7) – Forces entry into a method, including JDK methods.
Step Out (Shift+F8) – Exits the current method; often used together with (Force) Step Into.
Drop Frame – Returns to the caller method, restoring variable values to that point. Available only when the current method has a caller.
Run to Cursor (Alt+F9) – Executes code until the cursor position.
Evaluate Expression (Alt+F8) – Opens an expression evaluator to run any valid expression.
Trace Current Stream Chain – Traces the current Stream chain; button enabled only on Stream code.
Rerun Main (Ctrl+F5) – Restarts the program in debug mode.
Resume Program (F9) – Continues execution after a breakpoint; stops at the next breakpoint or runs to completion.
Stop Main (Ctrl+F12) – Stops the program.
View Breakpoints (Ctrl+Shift+F8) – Opens the breakpoint management window.
Mute Breakpoints – Disables all breakpoints.
Get Thread Dump – Retrieves a dump of current thread states.
Debugging Tips
Line Breakpoints
Click the left gutter of a line to add a red circular breakpoint.
Method Breakpoints
Place a breakpoint on a method declaration to stop when the method is invoked. This is useful for tracing implementations of interfaces or abstract methods.
public interface Service { void method(); } public class ServiceA implements Service { @Override public void method() { System.out.println("Service A"); } } public class ServiceB implements Service { @Override public void method() { System.out.println("Service B"); } } public class Main { public static void main(String[] args) { Service serviceB = new ServiceB(); serviceB.method(); } }Property Breakpoints
Click the gutter next to a field to add a watchpoint that triggers on read or write access.
Exception Breakpoints
Configure exception breakpoints via Ctrl+Shift+F8 → + → Java Exception Breakpoints, then add exceptions such as ArithmeticException. The debugger stops when the specified exception is thrown.
Temporary Breakpoints
Set a breakpoint and enable Remove once hit so it automatically disappears after being triggered once.
Breakpoint Conditions
Specify a condition (e.g., i % 2 == 0 or i == 5000) so the breakpoint triggers only when the expression evaluates to true.
Simulating Exceptions
Instead of inserting throw statements, use IDEA's Throw Exception action on a stack frame to inject an exception at runtime.
Multithread Debugging
When debugging multithreaded code, set breakpoint suspend mode to Thread to pause only the current thread, preserving execution order across threads.
Modifying Variables
During a breakpoint, edit variable values directly in the debugger to test alternative states without restarting the program.
Evaluating Code/Expressions
Use the Evaluate Expression window to run arbitrary code, invoke methods, or evaluate expressions on the fly.
Remote Debugging
Add a simple REST endpoint to the application, build the JAR, and start it with the JDWP agent (e.g.,
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5555). In IDEA, create a Remote Debug configuration with the same host and port, then attach to the running process.
@RestController
public class RemoteDebugController {
@GetMapping("debug")
public Integer debug(@RequestParam Integer p) {
System.out.println(p);
return p;
}
}After launching the application with the JDWP parameters, IDEA attaches, and you can set breakpoints (preferably with conditions) to debug live requests without affecting other users.
Conclusion
Leveraging IntelliJ IDEA's rich debugging capabilities—shortcuts, conditional breakpoints, exception simulation, multithread control, variable editing, and remote debugging—allows developers to diagnose and fix issues far more efficiently, turning a tedious debugging process into a powerful productivity boost.
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.
Java Interview Crash Guide
Dedicated to sharing Java interview Q&A; follow and reply "java" to receive a free premium Java interview guide.
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.
