Can't debug Java program in Intellij IDEA

20,597

Solution 1

If you're talking about debugging something running in Maven with IntelliJ, you can

  1. Run the maven build through IntelliJ and debug it like anything else, or
  2. Run your build using mvnDebug instead of just mvn. It will wait for a debugger to connect on port 8000. You can have IntelliJ do this by creating a Run/Debug Configuration of type "Remote" that connects to localhost:8000.

Solution 2

If you are facing with non-triggered breakpoints, see following: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360003676199-Can-t-debug-any-Java-or-Kotlin-application

In my case disabling android plugins solved the problem.

Solution 3

My solution was the following in IntelliJ. Go to:

Settings -> Build, Execution, Deployment-> Build Tools -> Maven -> Runner

Make sure to uncheck the box 'Delegate IDE build/run actions to Maven'

After that, I could debug and the breakpoints worked properly.

Share:
20,597
Konstantin Milyutin
Author by

Konstantin Milyutin

Updated on December 08, 2021

Comments

  • Konstantin Milyutin
    Konstantin Milyutin over 2 years

    For the first time I encounter problem when I can't debug Java program in Intellij IDEA. Output to command line works, but breakpoint is ignored.. May be it's because I created Maven configuration to start the program. It might be that I'm disconnected from JVM, but I have no idea how to connect to. What can be the cause of such behaviour?

  • Konstantin Milyutin
    Konstantin Milyutin over 12 years
    Thank you for answering. I created a configuration in IDEA analogous to the command line version: mvn clean test -P launch. So, I'm using first option you wrote. But it simply doesn't stop
  • Konstantin Milyutin
    Konstantin Milyutin over 12 years
    Thank you @Ryan, second way is working. If you can help me with first one, would be very nice!
  • Ryan Stewart
    Ryan Stewart over 12 years
    Surefire forks a process for running tests, which can mess with debugging. One way to overcome it is by adding -DforkMode=never to your mvn command line (put it in the "Goals" box in IntelliJ).
  • Gank
    Gank over 8 years
    but: Error running Unnamed Invalid arguments : Already listening [timeout, port, localAddress]