Java debug mode

Published: Sunday, 13 June 2010

JVM options

Add the following to the JVM options:

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

This means that when the JVM is started, it will listen on TCP port 5006 for remote Java debugging.

In Intellij, you can set this up as a remote configuration. I kept the default values:

Transport: socket

Debugger mode: attach

Port already in use

If the debug port is already in use, you may see the following error.

ERROR: transport error 202: bind failed: Address already in use
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [debugInit.c:750]
FATAL ERROR in native method: JDWP No transports initialized, jvmtiError=AGENT_ERROR_TRANSPORT_INIT(197)

Either change your port number, or find out what process is using the port.