Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
div
classnavigation
HTML Table
width100%
Table Row (tr)
Table Cell (td)
width50%
Align
alignleft
Previous
span
classsep
|
span
classtext
Intentions
Table Cell (td)
width50%
Align
alignright
Top
span
classsep
|
span
classtext
Quick Start

Wiki Markup
{div:class=navigation}
{table:width=100%}
{tr}
{td:width=33%}{align:left}[Previous|Version Control Basics] {span:class=sep}\| {span}{span:class=text}Version Control Basics{span}{align}{td}
{td:width=33%}{align:center}[Top|Quick Start] {span:class=sep}\| {span}{span:class=text}Quick Start{span}{align} {td}
{td:width=33%}{align:right}[Next|Keymap] {span:class=sep}\| {span}{span:class=text}Keymap{span}{align} {td}
{tr}
{table}
{div}
Wiki Markup
{redirect:https://www.jetbrains.com/idea/help/debugging-your-first-java-application.html|delay=0}

1. Run debug

After you have configured a run configuration for your project, you can run it in debug mode via

span
classshortcut
Shift
+
span
classshortcut
F9
shortcutby pressing
Wiki Markup
{span:class=shortcut}Shift{span}
+
Wiki Markup
{span:class=shortcut}F9{span}
.

In Debug tool window you can see the list of frames , and threads with it’s statetheir states, variables and watches. It’s worth to mention that when When you select a frame, you see the variables corresponding to the selected frame.

2. Useful debugger shortcuts

  • Toggle breakpoint via

    ...

    classshortcut

    ...

    span
    classshortcut
    F8

    ...

    span
    classshortcut
    Cmd

    ...

    classshortcut

    ...

    • Wiki Markup
      {span:class=shortcut}Ctrl{span}
      +
      Wiki Markup
      {span:class=shortcut}F8{span}
      (
      Wiki Markup
      {span:class=shortcut}Cmd{span}
      +
      Wiki Markup
      {span:class=shortcut}F8{span}
      for Mac)

    • Resume program via

      ...

      classshortcut

      ...

      • Wiki Markup
        {span:class=shortcut}F9{span}

      • Step over via

        ...

        classshortcut

        ...

        • Wiki Markup
          {span:class=shortcut}F8{span}

        • Step into via

          ...

          classshortcut

          ...

          classshortcut

          ...

          • Wiki Markup
            {span:class=shortcut}F7{span}

          • Stop via

            ...

            classshortcut

            ...

            span
            classshortcut
            F2

            ...

            span
            classshortcut
            Cmd

            ...

            classshortcut

            ...

            • Wiki Markup
              {span:class=shortcut}Ctrl{span}
              +
              Wiki Markup
              {span:class=shortcut}F2{span}
              (
              Wiki Markup
              {span:class=shortcut}Cmd{span}
              +
              Wiki Markup
              {span:class=shortcut}F2{span}
              )

            • View breakpoint details/all breakpoints via

              ...

              classshortcut

              ...

              span
              classshortcut
              Ctrl

              ...

              span
              classshortcut
              F8

              ...

              span
              classshortcut
              Shift

              ...

              span
              classshortcut
              Ctrl

              ...

              classshortcut

              ...

              • Wiki Markup
                {span:class=shortcut}Shift{span}
                +
                Wiki Markup
                {span:class=shortcut}Ctrl{span}
                +
                Wiki Markup
                {span:class=shortcut}F8{span}
                (
                Wiki Markup
                {span:class=shortcut}Shift{span}
                +
                Wiki Markup
                {span:class=shortcut}Ctrl{span}
                +
                Wiki Markup
                {span:class=shortcut}F8{span}
                )

              • Debug code at caret via

                ...

                classshortcut

                ...

                span
                classshortcut
                Ctrl

                ...

                • Wiki Markup
                  {span:class=shortcut}Shift{span}
                  +
                  Wiki Markup
                  {span:class=shortcut}Ctrl{span}
                  +
                  Wiki Markup
                  {span:class=shortcut}F9{span}
                  (e.g if you stay within

                ...

                • the main method)

                3. Smart step into

                Sometimes it happens that you stay at a line and want to step into a particular method but not the first one which will be invoked. In this case you can use Smart step into by pressing

                span
                classshortcut
                Ctrl
                +
                span
                classshortcut
                F7
                (
                span
                classshortcut
                Cmd
                + F7
                span
                classshortcut
                Wiki Markup
                {span:class=shortcut}Shift{span}
                +
                Wiki Markup
                {span:class=shortcut}F7{span}
                (
                Wiki Markup
                {span:class=shortcut}Cmd{span}
                +
                Wiki Markup
                {span:class=shortcut}F7{span}
                for Mac) to choose a particular method. This is a great time-saver.

                4. Drop frame

                In case if you want to “go back in time” while debugging you can do it via Drop Frame action. This is a great help if you mistakenly stepped too far. This will not revert the global state of your application but at least will get you back by stack of frames.

                ...

                Sometimes you need to resume the program and stop on at another line of code, without adding another break point. This is very easy via

                span
                classshortcut
                Alt
                + span
                classshortcut
                F9Easy: just press
                Wiki Markup
                {span:class=shortcut}Alt{span}
                +
                Wiki Markup
                {span:class=shortcut}F9{span}
                .

                6. Mark instance

                If you want a particular instance to be always recognized while debug debugging, you can mark it with a colored label via

                span
                classshortcut
                F11
                or a
                Wiki Markup
                {span:class=shortcut}F11{span}
                or the context menu in Variables and Watches tabs.

                ...

                The next time this instance appears in Watches, Variables or Evaluate expression, you will see the label.

                7. Evaluate expression

                Being While in debug mode you can evaluate any expression using very thevery powerful Evaluate expression tool via

                span
                classshortcut
                Alt
                +
                span
                classshortcut
                F8
                shortcutby pressing
                Wiki Markup
                {span:class=shortcut}Alt{span}
                +
                Wiki Markup
                {span:class=shortcut}F8{span}
                .

                This tool provides code completion just as in the editor so it’s very easy to enter any expression.

                ...

                If you have any instances marked with labels, code completion will offer you its names so you can evaluate them.

                8. Breakpoint details and condition

                If you want to change a breakpoint's details, you can press

                span
                classshortcut
                Shift
                +
                span
                classshortcut
                Ctrl
                +
                span
                classshortcut
                F8
                (
                span
                classshortcut
                Shift
                +
                span
                classshortcut
                Cmd
                +
                span
                classshortcut
                F8
                for Mac) shortcut. Here you can specify breakpoint condition.

                !debugger_breakpoint_details_2!

                Wiki Markup
                {span:class=shortcut}Shift{span}
                +
                Wiki Markup
                {span:class=shortcut}Ctrl{span}
                +
                Wiki Markup
                {span:class=shortcut}F8{span}
                (
                Wiki Markup
                {span:class=shortcut}Shift{span}
                +
                Wiki Markup
                {span:class=shortcut}Cmd{span}
                +
                Wiki Markup
                {span:class=shortcut}F8{span}
                for Mac). Here you can specify the breakpoint condition.

                Image Added

                And if you have any instance marked with a label, you can use it in the condition expression as well.

                Image Added

                To see all breakpoints in the project (with more advanced settings), press

                span
                classshortcut
                Shift
                +
                span
                classshortcut
                Ctrl
                +
                span
                classshortcut
                F8
                (
                span
                classshortcut
                Shift
                +
                span
                classshortcut
                Cmd
                +
                span
                classshortcut
                F8
                for Mac) shortcut
                Wiki Markup
                {span:class=shortcut}Shift{span}
                +
                Wiki Markup
                {span:class=shortcut}Ctrl{span}
                +
                Wiki Markup
                {span:class=shortcut}F8{span}
                (
                Wiki Markup
                {span:class=shortcut}Shift{span}
                +
                Wiki Markup
                {span:class=shortcut}Cmd{span}
                +
                Wiki Markup
                {span:class=shortcut}F8{span}
                for Mac) again.

                9. Field breakpoints

                Additionally In addition to conditional breakpoints you can also use Field breakpoints. These breakpoints stop when a field is accessed for read or write. To create such a breakpoint, just click on the gutter while holding

                Alt
                span
                classshortcut
                Wiki Markup
                {span:class=shortcut}Alt{span}
                .

                10. Action breakpoints

                Another action might be useful if you want to evaluate something at a particular line of code without actually making a stop. You can do that by using the Action breakpoint. To create one, just click on the gutter while holding

                Shift
                span
                classshortcut
                Wiki Markup
                {span:class=shortcut}Shift{span}
                .

                11. Temporary breakpoints

                To create a breakpoint which stops only once you , click on the gutter while holding

                span
                classshortcut
                Shift
                + Alt
                span
                classshortcut
                Wiki Markup
                {span:class=shortcut}Shift{span}
                +
                Wiki Markup
                {span:class=shortcut}Alt{span}
                .

                12. Disable breakpoints

                It is 's also worth useful to know that any breakpoint can be quickly disabled by clicking on the gutter while holding

                Alt
                span
                classshortcut
                Wiki Markup
                {span:class=shortcut}Alt{span}
                .

                13. Reload changes and hot swapping

                Sometimes it might happen that you need to put insert minor changes to in your code without shutting down the process. Since the Java VM has such a HotSwap feature as HotSwap , the IDE handles these cases automatically and - it offers you to reload the changed classes whenever you compile the changed classes being them while in debug mode.

                Keep in mind that Java VM’s HotSwap has a number of constraints and does not support reloading of static fields and methods.

                14. Remote debug

                And The final thing you definitely have to should know about debugging in IntelliJ IDEA is Remote debug. Remote debug means attaching debugger to a process which is already running on a specific port on your or any other’s host. This way you can attach the debugger to your application server which is running standalone.

                To create a remote configuration, go to Edit configurations and add Remote run configuration. Don’t forget Make sure to specify the correct host and port before you run this configuration.

                ...

                If you want to change the default settings how debugger works you can do it via

                span
                classshortcut
                Settings
                span
                classshortcut
                Debuggerdebugger settings, press
                Wiki Markup
                {span:class=shortcut}Settings{span}
                Wiki Markup
                {span:class=shortcut}Debugger{span}
                .

                ...

                classnavigation

                ...

                width100%

                ...

                Table Cell (td)
                width50%
                Align
                alignleft
                Previous
                span
                classsep
                |
                span
                classtext
                Intentions

                ...

                width50%

                ...

                alignright

                ...

                span
                classsep
                |

                ...

                classtext

                ...

                Wiki Markup
                {div:class=navigation}
                {table:width=100%}
                {tr}
                {td:width=33%}{align:left}[Previous|Version Control Basics] {span:class=sep}\| {span}{span:class=text}Version Control Basics{span}{align}{td}
                {td:width=33%}{align:center}[Top|Quick Start] {span:class=sep}\| {span}{span:class=text}Quick Start{span}{align} {td}
                {td:width=33%}{align:right}[Next|Keymap] {span:class=sep}\| {span}{span:class=text}Keymap{span}{align} {td}
                {tr}
                {table}
                {div}