When in Debug mode in Java there is something like a console, where can I enter commands?

Is it possible that there is a console in Eclipse where, when in debug mode, I can try something? Like in python, where can I enter at any moment, for example, 1 + 1 or myVariable.toString (), etc.? C # has a similar concept with the F # shell.

I would like to check my variables at runtime and try some methods, since such a console would be very useful.

thanks

+7
java eclipse
source share
3 answers

Eclipse has a Display view in which you can enter (almost) arbitrary Java expressions and evaluate them every time you are at a breakpoint.

To evaluate any expression, select it (either in the display view itself or in any open Java source file), and click one of the "inspect", "display" or "evaluate" buttons.

  • โ€œcheckโ€ executes the expression and shows the resulting value in a pop-up control view (similar to the โ€œVariablesโ€ view).
  • "display" executes the expression and prints the resulting value in the "View"
  • "evaluation" performs an expression and does nothing

There is some very good help with debugging in Eclipse , in particular about checking variables and evaluating extons .

If you want to test the behavior of any Java code until you debug it, you may need to learn about the Scrapbook function.

+11
source share

Yes. Eclipse scraps - little known but very cool

File -> Create -> Java -> Run / Debug Java -> Scrapbook

+2
source share

Eclipse also has an old plug-in that seems to do exactly what you are looking for, called Dr. Java

+1
source share

All Articles