Starting a JDB Session

Starting a JDB Session#

To start a program in JDB:

$ jdb MyClass

To start a program with remote debugging enabled:

$ java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n MyClass

To start a program with remote debugging enabled via a specific port:

$ java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000 MyClass

To enable remote debugging in Tomcat, edit <catalina.base>/conf/tomcat.conf as follows:

JAVA_OPTS="-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=8000"

To connect JDB to the program:

$ jdb -attach 8000

Threads#

To list threads:

> threads

To switch to a thread:

> thread <ID>

To suspend a thread:

> suspend <ID>

To display thread’s stack:

> where <ID>

See Also#