Example: Configuring a Breakpoint to Print a Message
(Integrated Debugger)
To experiment with configuring a breakpoint to run some Java code, try the following
example:
- If the Hanoi Sample package has not yet been added from the repository to the workspace,
add the package com.ibm.ivj.examples.hanoi from the IBM Java Examples project.
- Go to the com.ibm.ivj.examples.hanoi.Hanoi.main() method source code.
- Set a breakpoint by double-clicking on the margin next to the line that prints the
message "Puzzle solved!"
- Select Modify from the breakpoint symbol's pop-up menu.
- In condition field, type the following:
System.out.println("This is a true condition.");
true
Click OK.
- Run the Hanoi application. When it encounters the breakpoint, the string will be
output to the Console, and since the boolean value true is passed, the Debugger browser
will open and the main() thread will be suspended before the "Puzzle solved!"
string is output. Click the Resume button
to continue to the end of the
program.
- Go to the breakpoint in the main() method. Select Modify from its
pop-up menu.
- Edit the condition field, as shown:
System.out.println("This is a false condition.");
false
Click OK.
- Run the application again. This time, it prints the message, but since the value
false is passed, the program continues without suspending.
