In most programming languages I've used, when debugging, when I hit a breakpoint, I have the ability to execute arbitrary code (whatever I type into the console after the breakpoint has been hit).
How do I do this in Eclipse? The debugging mode has, by default, a display console, but no interactive console (into which I can input Java code for immediate execution)
Launching and Debugging a Java program A Java program can be debugged simply by right clicking on the Java editor class file from Package explorer. Select Debug As → Java Application or use the shortcut Alt + Shift + D, J instead.
It can be changed by going to Windows --> Preferences --> Run/Debug --> Console and then unchecking "Limit Console Output" which is ON by default. This works on STS any version too. This would help printing complete console output. For a Mac it is Eclipse > Preferences > Run/Debug > Console.
The console in Eclipse is interactive, when a running application reads from the Console Input Stream. It is not meant to be a feature of Eclipse to generally aid in debugging, it is meant to allow console based Java applications to read input from the user when debugging (as in I can type into a console prompt).
The first way is by calling Display. getCurrent. A display is forever tied to the thread that created it, and a thread can have only one active display; a display is active until it is disposed of. A calling thread that does not have an active display will return null.
You can use the Display view to execute arbitrary code, access it via:
window->Show View->Display
then type the code you want to execute (you can use CTRL+SPACE
for autocomplete).
to execute the code, select it then:
CTRL+SHIFT+D
That should execute the code based on the breakpoint you've hit.
Note: As of 2018, Display View has been renamed to Debug Shell View.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With