Example: Using a Conditional Breakpoint (Integrated Debugger)

To see the effect of a conditional breakpoint, try the following example:

  1. 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.
  2. Go to the com.ibm.ivj.examples.hanoi.Hanoi.main() method source code.
  3. Set a breakpoint by double-clicking on the margin next to the line that prints the message "Puzzle solved!"
  4. Select Modify from the breakpoint symbol's pop-up menu.
  5. In condition field, type the following condition:
    numberOfDisks == 4
  6. Click OK.
  7. Select Properties from the Hanoi application class' pop-up menu.
  8. On the Program page, enter 4 in the Command Line Arguments field (this argument sets the number of disks used in the program).

Run the Hanoi application.  The condition on the breakpoint will evaluate to true; the Debugger browser will open, with the main() thread suspended at the System.out.println ("Puzzle Solved!") line.  Click Resume resume.gif (1020 bytes) to finish running the program.

Now, change the Command Line Arguments field in the Hanoi class' Properties dialog to 5.  Run the program again.  This time, the condition on the breakpoint will evaluate to false, and so the thread will not be suspended.