Just tried that.
jdb - The Java Debugger
jdb helps you find and fix bugs in Java language programs.
SYNOPSIS
jdb [ options ] [ class ] [ arguments ]
options
Command-line options, as specified below.
class
Name of the class to begin debugging.
arguments
Arguments passed to the main() method of class.
Java Platform Debugger Architecture that provides inspection and debugging of a local or remote Java Virtual Machine.
Starting a jdb Session
There are many ways to start a jdb session. The most frequently used way is to have
jdb launch a new Java Virtual Machine (VM) with the main class of the application to be debugged. This is done by substituting the command
jdb for
java in the command line. For example, if your application's main class is MyClass, you use the following command to debug it under JDB:
C:\> jdb MyClass
When started this way,
jdb invokes a second Java VM with any specified parameters, loads the specified class, and stops the VM before executing that class's first instruction.
Another way to use
jdb is by attaching it to a Java VM that is already running. A VM that is to be debugged with
jdb must be started with the following options. These options load in-process debugging libraries and specify the kind of connection to be made.
-agentlib:jdwp=transport=dt_shmem,server=y,suspend=n
For example, the following command will run the MyClass application, and allow
jdb to connect to it at a later time.
C:\> java -agentlib:jdwp=transport=dt_shmem,address=jdbconn,server=y,suspend=n MyClass
You can then attach
jdb to the VM with the following commmand:
C:\> jdb -attach jdbconn
Note that "MyClass" is not specified in the
jdb command line in this case because
jdb is connecting to an existing VM instead of launching a new one.
There are many other ways to connect the debugger to a VM, and all of them are supported by
jdb. The Java Platform Debugger Architecture has additional
documentation on these connection options. For information on starting a J2SE 1.4.2 or early VM for use with
jdb see
1.4.2 documentation
Basic jdb Commands
The following is a list of the basic
jdb commands. The Java debugger supports other commands which you can list using
jdb's help command.
help, or
?
The most important
jdb command, help displays the list of recognized commands with a brief description.
run
After starting
jdb, and setting any necessary breakpoints, you can use this command to start the execution the debugged application. This command is available only when
jdb launches the debugged application (as opposed to attaching to an existing VM).
cont
Continues execution of the debugged application after a breakpoint, exception, or step.
print
Displays Java objects and primitive values. For variables or fields of primitive types, the actual value is printed. For objects, a short description is printed. See the dump command below for getting more information about an object.
NOTE: To display local variables, the containing class must have been compiled with the javac -goption.
print supports many simple Java expressions including those with method invocations, for example:
- print MyClass.myStaticField
- print myObj.myInstanceField
- print i + j + k (i, j, k are primities and either fields or local variables)
- print myObj.myMethod() (if myMethod returns a non-null)
- print new java.lang.String("Hello").length()