Norm Matloff's Introduction to the jdb Java Debugger

The jdb Java debugger, which comes with the Java package, is very, very primitive. It not only lacks powerful commands, but it does not even have any means of reducing the number of keystrokes one uses.

However, the latter problem can be resolved by using the ddd GUI (use at least version 3.3 if possible), in which case jdb is fairly usable. Instead of repeatedly typing "next", you can repeatedly click on the Next button, etc. Invoke ddd as follows:

ddd --jdb
<class name>. 

You'll have to load the .java file yourself, clicking on File then on Open Source.

Starting up jdb:

First, make sure that the program has been compiled using the -g option of javac. Then type

jdb <class name>

Setting breakpoints:

There are two forms:

stop at <class name>:<line number>
stop in <class name>.<method name>

Starting execution of your program:

First, set a breakpoint at main(). Then

run <class name> <command-line arguments>

Make sure you don't forget the class name; otherwise you will get a "URLClassLoader not found" error message.

When you then use the "list" command, breakpoints will show up with arrow marks.

Stepping through the code:

The step, next and cont commands work like their counterparts in gdb.

Listing lines in the source file:

list <classname>:<line number>

Printing the values of variables:

Use the "print" command. A drawback is that static variables are not accessible.

Exiting jdb:

Use the "quit" command.

Click on New Class to make a new class file. The editor window will pop up, and you can start typing.