How to write Debugger Netbeans console (in Java)?

Netbeans has a tabbed window in the Output section called the Debugger Console. Is it possible to write a message to this window using Java? If so, how?

+4
source share
2 answers

Messages that you see in the debugger console, or

  • information provided by the debugger itself (e.g. breakpoint)
  • custom breakpoint related messages

When you add a breakpoint to a line of code, the default behavior of a breakpoint is to pause the thread that executed the line of code and print the text "Breakpoint hit at line {lineNumber} in class {className} by thread {threadName}." .

You can set a breakpoint to print custom text. This text will be displayed in the debugger console when it reaches a breakpoint. To do this, right-click the breakpoint, open the propoerties window, and enter text in the Print text box.

A useful trick is to set a breakpoint so that it does not block ( suspend : no thread ), and enter the text. The effect is the same as adding println lines to your code, but the advantage is that you do not need to recompile the code, and it is easier to activate / deactivate these debugger logs (and, obviously, it does not remain on the production code).

Note that in the breakpoint text you can use one of the special values {lineNumber} , {methodName} , {className} or {threadName} , and you can also evaluate some code with the syntax {=xxx} . Just replace xxx with the name variable or method call or something else.

+14
source

OK for me, this is in the Output> Glassfish server 3+ Console window

I just wrote the System.out.println program in my program, and when the debugger came to this instruction, the diplay console will get the result of my simple writing.

For other situations, I do not know

+1
source

Source: https://habr.com/ru/post/1344356/


All Articles