Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In eclipse, while debugging, how do I access the interactive-top-level (a.ka. the "display console")?

Tags:

java

eclipse

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)

like image 779
Aaron Fi Avatar asked May 16 '09 01:05

Aaron Fi


People also ask

How do I open Debug console in Eclipse?

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.

How do I open the full console in Eclipse?

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.

Does Eclipse have an interactive debugger?

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).

How do I get display in Eclipse?

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.


1 Answers

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.

alt text

Note: As of 2018, Display View has been renamed to Debug Shell View.

like image 77
Jon Avatar answered Sep 21 '22 02:09

Jon