NonStop Server for Java 7.0 Tools Reference Pages

11 jdb: Java Debugger
The jdb tool helps you to find and fix errors in Java programs. For more information on jdb tool,
see the Oracle Java documentation for jdb.
Synopsis
jdb [ options ] [ class ] [ arguments ]
options
See “Command Line Options (page 31).
class
Name of the class to begin debugging.
arguments
Arguments passed to the main() method of class.
Description
The Java Debugger, jdb, is a simple command line debugger for Java classes. It is an example
of the use of the Java Platform Debugger Architecture that provides inspection and debugging of
a local or remote Java virtual machine (VM).
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. Perform 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:
PurposeOption
Enables debugging support in the Java VM.-Xdebug
Loads in-process debugging libraries and specifies the kind
of connection to be made.
agentlib:jdwp=transport=dt_socket,
server=y,suspend=n
For example, the following command runs the MyClass application and allows jdb to connect
to the application at a later time.
java -Xdebug agentlib:jdwp=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” (page 33).
Synopsis 29