NonStop Server for Java 4.2 Tools Reference

Starting a jdb Session
There are many ways to start a jdb session. The most frequent way is to have jdb launch a
new Java VM with the main class of application to be debugged. You do this by substituting
the command jdb for the command java in the command line. For example, if your
application's main class is named MyClass, you use the following command to debug it
under JDB:
jdb MyClass
When started this way, jdb invokes a second Java VM with any specified parameters, loads
the specified class, and stops the Java VM before executing the first instruction of that class.
Another way to use jdb is by attaching it to a Java VM that is already running. A Java VM
that is to be debugged with jdb must be started with the following java options:
Option Purpose
-Xdebug
Enables
debugging
support in the
Java VM.
-Xrunjdwp:transport=dt_socket,
server=y,suspend=n
Loads
in-process
debugging
libraries and
specifies the
kind of
connection to
be made.
For example, the following command runs the MyClass application and allows jdb to
connect to the application at a later time.
java -Xdebug -Xrunjdwp:transport=dt_socket,\
address=8000,server=y,suspend=n MyClass
You can then attach jdb to the Java VM with the following command:
jdb -attach 8000
Note: MyClass is not specified in the jdb command line in this case because
jdb connects to an existing Java VM instead of launching a new one.
There are many other ways to connect the debugger to a Java VM, and all of them are
supported by jdb, as specified in Connecting for Remote Debugging.