Java Reference
In-Depth Information
This example runs the debugger with WriteBytes.class , an application that's available
from the topic's website at http://www.java21days.com. Visit the site, select the
Appendix B page, and then save the files WriteBytes.class and WriteBytes.java in
the same folder that you run the debugger from.
The WriteBytes application writes a series of bytes to disk to produce the file pic.gif .
The debugger loads this program but does not begin running it, displaying the following
output:
Initializing jdb...
>
The debugger is controlled by typing commands at the > prompt.
To set a breakpoint in a program, the stop in or stop at commands are used. The stop
in command sets a breakpoint at the first line of a specific method in a class. You spec-
ify the class and method name as an argument to the command, as in the following hypo-
thetical example:
stop in SellItem.SetPrice
This command sets a breakpoint at the first line of the SetPrice method. Note that no
arguments or parentheses are needed after the method name.
The stop at command sets a breakpoint at a specific line number within a class. You
specify the class and number as an argument to the command, as in the following exam-
ple:
stop at WriteBytes:14
If you're trying this with the WriteBytes class, you'll see the following output after
entering this command:
Deferring breakpoint WriteBytes:14
It will be set after the class is loaded.
You can set as many breakpoints as desired within a class. To see the breakpoints that are
currently set, use the clear command without any arguments. The clear command lists
all current breakpoints by line number rather than method name, even if they were set
using the stop in command.
By using clear with a class name and line number as an argument, you can remove a
breakpoint. If the hypothetical SellItem.SetPrice method was located at line 215 of
SellItem , you can clear this breakpoint with the following command:
clear SellItem:215
Search WWH ::




Custom Search