Debugging my code in IntelliJ

2020-03-21 10:43发布

问题:

I am using JBoss with IntelliJ. I am running Jboss outside intellij. i.e running in Command Prompt. If that is the case, Can I debug my code in IntelliJ

回答1:

You can debug any running JVM, even remote on a different computer via JDWP. First you need to prepare JBoss (same thing applies to any JVM) to listen for debugger connections on a given TCP/IP port:

-Xdebug -Xrunjdwp:server=y, transport=dt_socket,address=5005, suspend=n

This set of parameters has to be added to Java options, look for JAVA_OPTS variable in your JBoss startup scripts. Once this is done, JBoss will listen on 5005 port for debugger connection. The very first line in JBoss console after starting it up should be:

Listening for transport dt_socket at address: 5005

Now you can attach your IntelliJ by choosing:

  1. Run
  2. Edit configurations
  3. "+" (Add)
  4. Remote
  5. localhost/5005 are fine