A Java program can run to completion even when it calculates the wrong value. In IntelliJ IDEA on the Linux desktop, a line breakpoint pauses the program before a chosen statement runs, so you can inspect the values it is about to use.

The line must contain an executable statement that your program will reach. A breakpoint on a print statement, for example, lets you inspect the local variables that were assigned earlier in the method.

The editor gutter is the strip beside the line numbers. A red dot there marks where you asked the debugger to stop. When the program reaches that breakpoint in a debug session, IntelliJ IDEA highlights the line and shows the suspended method call and its variables in the Debug tool window.

Steps to set a debugger breakpoint in JetBrains IDE:

Start with a trusted, runnable local Java project, its entry-point class open in the editor, and breakpoints unmuted. The example shows Main.java in ~/IdeaProjects/order-totals with the Project tool window open. If you see the Air landing page or a Junie offer, step 1 starts once your Java file is open.

  1. Click the gutter beside the executable line you want to pause on, where there is no breakpoint yet.

    The example uses the System.out.println(subtotal + shipping); line, after both variables have been assigned. PyCharm uses the same gutter click for a line breakpoint in Python.

  2. Click the green Run icon in the gutter beside your entry-point method.
  3. Select Debug 'Main.main()', using the Debug entry for your own method if it has a different name.

    The Debug tool window may show the Console during startup. Once execution pauses at the breakpoint, the local values load in Threads & Variables.

  4. Confirm that Threads & Variables in the Debug tool window shows a suspended frame for your chosen line with the local values you wanted to inspect.

    In the example, the editor highlights line 5, the selected frame reads main:5, Main, and the local values are subtotal = 12 and shipping = 3.

Share this guide