简体   繁体   中英

When in Debug mode in Java, is there anything like a Console where I can type commands?

Is it possible in Eclipse to have a Console, where when in Debug mode I can try out things? Like in python, where I can type at any moment for example 1+1 or myVariable.toString(), etc? C# has a similar concept with the F# shell.

I'd like to inspect my variables at run-time and try out some methods, having that kind of console would be of great help.

Thanks

Eclipse has the Display view, where you can enter (almost) arbitrary Java expressions and have them evaluated whenever you are in a breakpoint.

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

  • "inspect" executes the expression and shows the resulting value in a pop-up inspection view (similar to the Variables view).
  • "display" executes the expression and prints the resulting value into the Display view
  • "evaluate" executes the expression and does nothing else

There some very good help on debugging in Eclipse , specifically about inspecting variables and evaluating expressons .

If you want to test the behavior of some Java code while you're not debugging, then you might want to look into the Scrapbook feature .

Yes. Eclipse scrapbook - little known but very cool

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

Eclipse也有一个旧的插件,似乎正在寻找你正在寻找的名为Dr. Java的插件。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM