调试java程序时如何在eclipse中执行某些功能?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/950129/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to execute some function in eclipse while debugging a java program?
提问by omg
Like firebug for debugging javascript,
就像调试javascript的firebug一样,
is there such a feature in eclipse? or do I need a plugin?
eclipse 有这样的功能吗?还是我需要一个插件?
回答by Michael Borgwardt
I believe that what you're looking for are "watch expressions". Just mark the piece of code in the source code view, right-click and select "Watch".
我相信您正在寻找的是“手表表达式”。只需在源代码视图中标记该段代码,右键单击并选择“观看”即可。
回答by mR_fr0g
You can use the Display view to execute commands while debugging. You can find this in Window -> Show View -> Display
您可以在调试时使用显示视图执行命令。您可以在窗口 -> 显示视图 -> 显示中找到它
回答by Gareth Davis
you can use the 'Display' view to evaluate expressions in eclipse.
您可以使用“显示”视图来评估 eclipse 中的表达式。
Look under the debug list of views. It is a standard par part of the java tooling so you don't need a plugin
查看调试列表下的视图。它是 Java 工具的标准部分,因此您不需要插件
回答by banjollity
Use the Display view, or a bit quicker: highlight the code you want to run and right-click/Execute or Ctrl+U.
使用“显示”视图,或者更快一点:突出显示要运行的代码并右键单击/执行或 Ctrl+U。
回答by wds
You can also create a scrapbook page (a .jpage) file and type your code in there. Then click run. It looked slightly more convenient when I tried it.
您还可以创建剪贴簿页面(.jpage)文件并在其中键入您的代码。然后点击运行。当我尝试时,它看起来稍微方便了一些。
回答by Vinoj John Hosan
Select the line and press ctrl+shift+D
or ctrl+shift+I
This will give the result in a popup.
选择该行并按ctrl+shift+D
或ctrl+shift+I
这将在弹出窗口中给出结果。
回答by Alberto Alegria
Complementing all the amazing answers, for mac users is cmd + D
补充所有惊人的答案,对于 mac 用户是 cmd + D
回答by Mr. Butterworth
I'm currently using Eclipse Photon (v4.8.0). Eclipse changed the "Display" View name to "Debug Shell View". Here, you can execute commands on-the-fly.
我目前正在使用 Eclipse Photon (v4.8.0)。Eclipse 将“显示”视图名称更改为“调试外壳视图”。在这里,您可以即时执行命令。
回答by Ronak Shah
Use the debug shell! Coming from node, I was pretty used to being able to mess with my env variables at any time using node --inspect
in chrome, and so it was imperative for me to find the same experience in eclipse without having to use JDB.
使用调试外壳!来自 node,我非常习惯于node --inspect
在 chrome中随时使用我的 env 变量,因此我必须在 eclipse 中找到相同的体验,而不必使用 JDB。
To open the debug shell, go to Window → Show View → Debug Shell
要打开调试外壳,请转到窗口 → 显示视图 → 调试外壳
After you write the code you wish to run, simply highlight it, right click, and execute (?U also works)
编写好要运行的代码后,只需突出显示它,右键单击并执行(?U 也可以)
回答by behold
Like others say, you use the Display view. But for some variants of Eclipse, it may be named differently. For instance, if you are using Spring Tool Suite as your Eclipse, the View name corresponding to Display view is Debug Shell.
就像其他人说的那样,您使用“显示”视图。但是对于 Eclipse 的某些变体,它的名称可能有所不同。例如,如果您使用 Spring Tool Suite 作为 Eclipse,则 Display 视图对应的视图名称是 Debug Shell。