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:

  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:
    System.out.println("This is a true condition.");
    true

    Click OK.

  6. 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 resume.gif (1020 bytes) to continue to the end of the program.
  7. Go to the breakpoint in the main() method.  Select Modify from its pop-up menu.
  8. Edit the condition field, as shown:
    System.out.println("This is a false condition.");
    false

    Click OK.

  9. Run the application again.  This time, it prints the message, but since the value false is passed, the program continues without suspending.