简体   繁体   English

如何在调试java程序时在eclipse中执行某些功能?

[英]How to execute some function in eclipse while debugging a java program?

Like firebug for debugging javascript, 像firebug一样调试javascript,

is there such a feature in eclipse? eclipse中有这样的功能吗? or do I need a plugin? 还是我需要一个插件?

使用“显示”视图或更快一点:突出显示要运行的代码,然后右键单击/执行或按Ctrl + U.

You can use the Display view to execute commands while debugging. 您可以使用“显示”视图在调试时执行命令。 You can find this in Window -> Show View -> Display 您可以在窗口 - >显示视图 - >显示中找到它

选择该行并按ctrl+shift+Dctrl+shift+I这将在弹出窗口中显示结果。

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". 只需在源代码视图中标记该段代码,右键单击并选择“Watch”。

Use the debug shell! 使用调试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. 从节点开始,我习惯于在任何时候使用chrome中的node --inspect来弄乱我的env变量,因此我必须在eclipse中找到相同的体验而不必使用JDB。

To open the debug shell, go to Window → Show View → Debug Shell 要打开调试shell,请转到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也可以)

使用调试shell

I'm currently using Eclipse Photon (v4.8.0). 我目前正在使用Eclipse Photon(v4.8.0)。 Eclipse changed the "Display" View name to "Debug Shell View". Eclipse将“显示”视图名称更改为“调试Shell视图”。 Here, you can execute commands on-the-fly. 在这里,您可以即时执行命令。

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工具的标准部分,因此您不需要插件

You can also create a scrapbook page (a .jpage) file and type your code in there. 您还可以创建剪贴簿页面(.jpage)文件并在其中键入代码。 Then click run. 然后单击运行。 It looked slightly more convenient when I tried it. 当我尝试它时看起来稍微方便一些。

补充所有惊人的答案,对于mac用户是cmd + D.

Like others say, you use the Display view. 像其他人说的那样,你使用Display视图。 But for some variants of Eclipse, it may be named differently. 但是对于Eclipse的某些变体,它的名称可能不同。 For instance, if you are using Spring Tool Suite as your Eclipse, the View name corresponding to Display view is Debug Shell. 例如,如果您使用Spring Tool Suite作为Eclipse,则与Display视图对应的View名称是Debug Shell。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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