The debugger allows you to debug your Java code at the source level. You can use the debugger to set breakpoints and view source variables, stacks, and threads. The debugger is implemented using the APIs in the package sun.tools.debug. The debugger is a sample of how to use the debugger APIs. It is not intended to be a product-level debugger. It debugs Java source code that has a main method. It cannot debug applets. The features of the debugger are as follows:
Breakpoints | You can control how your program executes by setting breakpoints. A breakpoint stops the execution of your program at a specific location. |
Call Stack Window | The Call Stack window lists the active functions. The functions are displayed in the order that they were called. |
Variables Window | The Variables window lists the variables for the current execution point. The contents of the Variables window change each time your program enters or leaves a function. |
Debugger Console | The Debugger Console displays debugger-generated messages and output from System.out.println statements. |
The debugger is a packaged zip file. Copy and unzip the file onto your computer and add the zip file to your CLASSPATH environment variable.
To start the debugger, type the following line at a command prompt.
java com.ibm.beans.tools.debugger.BeanDbgMainThe Title Bar contains several buttons. Each icon with its corresponding action is in the following list.
![]() | The Split Vertical button lets you control how a panel is split. Select the panel you want to split and click on the button. The panel is split vertically. |
![]() | The Split Horizontal button lets you control how a panel is split. Select the panel you want to split and click on the button. The panel is split horizontally. |
![]() | The Debugger Console button adds a panel containing the debugger console. |
![]() | The Source button adds the source panel to the debugger window. |
![]() | The Variable button adds the panel that displays the variables for the current execution point. |
![]() | The Stack button adds the panel that displays the current call stack. |
![]() | The Threads button adds the panel that displays the current threads. |
![]() | The Step button executes the current line of the program. If the current line is a call, execution is halted at the first statement in the called function. |
![]() | The Next button executes the current line in the program. If the current line is a call, execution is halted when the call is completed. |
![]() | The Continue button continues executing the program until the next breakpoint occurs or until the end of the program is reached. |
![]() | The Debug button starts the debugger. When you click on this button, the
following process starts:
|
The Source panel allows you to view the program you are debugging. The
Source panel shows both the source and the line numbers. In the following
example, the system is stopped at line 8 and a breakpoint is set on line 13.
To set or remove a breakpoint, double click on the line number.
The Call Stack window displays the current call stack. The following
figure shows an example of a Call Stack Window.
The Variable panel displays the variables for the current execution
point. The following figure is an example of the Variable panel.
The Debugger Console displays messages from the debugger and output
from the System.out.println statements. The following figure is the Debugger
Console.
The Threads panel displays the thread at the current execution point. The panel shows the thread for the system, main program, and the running programs. Click on the plus (+) to expand or on the minus (-) to collapse each category.
The following figure is the Threads panel.
The Debugger saves its state automatically when it is closed. This file is saved in a file named beanDbgSave. The window layout and breakpoints are saved.