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)
如何在Eclipse中进行此操作?在默认情况下,调试模式有一个显示控制台,但是没有交互式控制台(我可以在其中输入Java代码以立即执行)
2 个解决方案
#1
89
You can use the Display view to execute abritary code, access it via:
您可以使用显示视图执行代码,通过以下方式访问:
window->Show View->Display
窗口- >显示视图- >显示
then type the code you want to execute (you can use CTRL+SPACE
for autocomplete).
然后输入要执行的代码(可以使用CTRL+SPACE进行自动完成)。
to execute the code, select it then:
要执行代码,请选择:
CTRL+SHIFT+D
CTRL + SHIFT + D
That should execute the code based on the breakpoint you've hit.
它应该基于所命中的断点执行代码。
alt text http://i39.tinypic.com/1z4jsd0.gif
alt文本http://i39.tinypic.com/1z4jsd0.gif
#2
2
Eclipse has it indeed. Window->Show View->Interactive Console. Note that you can also execute expressions in the Watch view (e.g. result=false, exception.printStackTrace() etc.).
Eclipse确实。窗口- >显示视图- >交互式控制台。注意,您还可以在Watch视图中执行表达式(例如result=false, exception.printStackTrace()等)。
#1
89
You can use the Display view to execute abritary code, access it via:
您可以使用显示视图执行代码,通过以下方式访问:
window->Show View->Display
窗口- >显示视图- >显示
then type the code you want to execute (you can use CTRL+SPACE
for autocomplete).
然后输入要执行的代码(可以使用CTRL+SPACE进行自动完成)。
to execute the code, select it then:
要执行代码,请选择:
CTRL+SHIFT+D
CTRL + SHIFT + D
That should execute the code based on the breakpoint you've hit.
它应该基于所命中的断点执行代码。
alt text http://i39.tinypic.com/1z4jsd0.gif
alt文本http://i39.tinypic.com/1z4jsd0.gif
#2
2
Eclipse has it indeed. Window->Show View->Interactive Console. Note that you can also execute expressions in the Watch view (e.g. result=false, exception.printStackTrace() etc.).
Eclipse确实。窗口- >显示视图- >交互式控制台。注意,您还可以在Watch视图中执行表达式(例如result=false, exception.printStackTrace()等)。