30+ IntelliJ IDEA Debugging Tips and Tricks to Boost Your Efficiency
This article presents a comprehensive collection of over thirty IntelliJ IDEA debugging features, shortcuts, and advanced techniques—including breakpoint types, conditional breakpoints, remote debugging, and code evaluation—to help Java developers dramatically improve their debugging workflow and productivity.
IDEA Debugging Features Overview
The IDEA debug console is located at the lower left of the IDE window.
IDEA Debugging Functions
Show Execution Point (Alt + F10) – Returns to the current active breakpoint line.
Step Over (F8) – Executes the current line without entering called methods.
Step Into (F7) – Enters the body of a method; does not enter JDK methods.
Force Step Into (Alt + Shift + F7) – Forces entry into JDK methods as well.
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 (only available when a caller exists).
Run to Cursor (Alt + F9) – Executes code until the cursor position.
Evaluate Expression (Alt + F8) – Opens an expression evaluator to run any valid Java expression.
Trace Current Stream Chain – Available only when the cursor is on a Stream pipeline.
Rerun Main (Ctrl + F5) – Restarts the main method in debug mode.
Resume Program (F9) – Continues execution until the next breakpoint or program end.
Stop Main (Ctrl + F12) – Terminates the running program.
View Breakpoints (Ctrl + Shift + F8) – Opens the breakpoint management dialog.
Mute Breakpoints – Disables all breakpoints temporarily.
Get Thread Dump – Captures the current thread state for analysis.
Debugging Tips
Line Breakpoint
Click the red circular icon at the left of a code line to add a line breakpoint.
Method Breakpoint
Place a breakpoint on a method declaration; when the method is invoked, execution stops inside it. 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();
}
}Conditional Breakpoint
Set an expression (e.g., i % 2 == 0 ) so the breakpoint only triggers when the condition is true.
Temporary Breakpoint
A breakpoint that automatically removes itself after being hit once.
Exception Breakpoint
Configure IDEA to stop execution when a specific exception (e.g., ArithmeticException ) is thrown.
Simulating Exceptions
Instead of adding throw statements, use IDEA’s "Throw Exception" feature on a paused frame to inject an exception.
Multithreaded Debugging
Change the breakpoint suspend policy from all to thread to step through each thread sequentially.
Modifying Variables
During a pause, edit variable values directly in the debugger to test alternative flows without restarting.
Executing Code/Expressions at Breakpoints
Run arbitrary code snippets.
Invoke methods.
Evaluate expressions.
Remote Debugging
Add a simple REST endpoint, package the application as a JAR, start it with JDWP agent parameters (e.g., -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5555 ), and configure IDEA to attach to the remote JVM.
@RestController
public class RemoteDebugController {
@GetMapping("debug")
public Integer debug(@RequestParam Integer p) {
System.out.println(p);
return p;
}
}After launching the JAR with the JDWP options, IDEA can set breakpoints, and when a client request hits the endpoint, the debugger stops, allowing inspection and modification of runtime state.
Conclusion
Mastering these IDEA debugging capabilities turns a time‑consuming debugging process into a fast, efficient workflow, enabling developers to locate and fix bugs quickly and even perform sophisticated tasks like remote debugging and exception simulation.
IT Services Circle
Delivering cutting-edge internet insights and practical learning resources. We're a passionate and principled IT media platform.
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.