FaqDebuggingPrints

Printing debug messages

A common way how to debug an application is to insert debug outputs into suspicious places. However, this requires recompilation and restart of the application.

With NetBeans debugger, recompilation and restart is no longer required. You can insert breakpoints to the desired places, set the breakpoints not to suspend any thread and just print the desired information out.

Steps:

  1. Insert a line breakpoint in the editor with a mouse-click on the left side gutter of the editor window.
  2. Right-click on the breakpoint icon (a red square) and select Breakpoint > Properties (or Breakpoint > Customize in older NetBeans versions).
  3. Set Suspend to "No thread (continue)".
  4. Fill in the desired "Print Text"
    To print out values of variables, put "{=<var name>}" there, like "Index i = {=i}".
    You can have method calls there as well, e.g.: "Current instance = {=toString()}".
  5. Run the debugger and watch Debugger Console in the Output window.



Applies to: NetBeans 5.5, 6.x

Platforms: All

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo