How skip line in Intellij idea debug?

It's not possible with the debugger to not execute parts of the code.

It is however possible to execute extra code and change values on variables so if you need to exclude one row from execution during debug you will have to alter your code to prepare for that kind of debugging.

public void someMethod() {
    int a = 3;
    int b = 2;
    boolean shouldRun = true;
    if (shouldRun) {
        a = b + 2;
    }
    System.out.prinln(a);
}

You would then set a break point that changes the value of shouldRun without stopping execution. It can be done like this.

enter image description here

Note that

  1. Suspend isn't checked
  2. Log evaluated expression is used to alter a variable when the break point is hit

You can't just skip 'line execution' when debugging. You can press F8 to step over.


It is possible to skip lines only if you use hotswapping, or put in other words, code reloading tool - add code changes/new code at runtime. Hotswapping is the functions of replacing components without shutting down the system. Hotswapping can also refer to the ability to alter the running code of a program without needing to interrupt its execution.

There are various hotswapping tools like: JRebel (https://zeroturnaround.com/software/jrebel/) or HotSwapAgent (http://www.hotswapagent.org/)

You avoid having to rebuild the entire application to reload code changes, this is a huge time savings. Instead of running your full build process, simply use the compiler built into your IDE and the hotSwap agent/tool will reload the code into the JVM.

In this case, it would not be actually skipping, but you can just comment/change the lines and reload it. This tools are quite awesome!!!! It greatly speeds up the development/debugging process.


IntelliJ recently published a blog post about a plugin called Jump to Line that can accomplish this, even though IntelliJ itself doesn't have this functionality. It really is surprising that IntelliJ still doesn't have this functionality, when Visual Studio has had it for so many years!

https://blog.jetbrains.com/idea/2020/08/jump-to-any-line-while-debugging/