简体   繁体   English

在没有断点的情况下逐行启动Eclipse的Java调试器

[英]Start Eclipse's Java debugger line by line without breakpoints

A nice thing that you can do in Visual Studio is to start your program and stop it to debug in the very first line, just by pressing F10 for line by line debugging. 在Visual Studio中可以做的一件好事就是启动程序并在第一行停止调试,只需按F10进行逐行调试即可。 This is extremely useful when writing sample code or trying something new. 在编写示例代码或尝试新内容时,这非常有用。

Is there a way to do this in Eclipse for a Java program? 有没有办法在Eclipse中为Java程序执行此操作? You can't start with line by line because that option is not enabled until you actually start debugging. 您不能一行一行地开始,因为在您实际开始调试之前不会启用该选项。

I know I could set a breakpoint at the very first line, but then I would have to remove it to actually debug something else. 我知道我可以在第一行设置一个断点,但是我必须删除它以实际调试其他内容。

bounty: for exact answers to the question (if it is even possible) and not a workaround. 赏金:问题的确切答案(如果可能的话),而不是解决方法。

The debug configuration for each program has ab option/checkbox “stop in main”. 每个程序的调试配置都有ab选项/复选框“stop in main”。 This will do what you describe. 这将做你所描述的。

http://help.eclipse.org/indigo/topic/org.eclipse.jdt.doc.user/tasks/tasks-java-local-configuration.htm http://help.eclipse.org/indigo/topic/org.eclipse.jdt.doc.user/tasks/tasks-java-local-configuration.htm

The "stop in main" mentioned by Holger is to be declared in a launched configuration: Holger 提到的“stop in main”将在已启动的配置中声明:

http://help.eclipse.org/indigo/topic/org.eclipse.jdt.doc.user/tips/images/org.eclipse.jdt.debug.ui/stop_in_main.png

The problem is to call that specific configuration from a keyboard shortcut, especially when this isn't always the last one you just launched 问题是从键盘快捷方式调用该特定配置,尤其是当这不是您刚刚启动的最后一个时
(if it were, you could use the shortcut "Run last launched" Ctrl + F11 ). (如果是,您可以使用快捷方式“运行最后一次启动” Ctrl + F11 )。

You can assign a shortcut to open the "run configurations" window , but then you need to select the right configuration to launch. 您可以指定快捷方式以打开“运行配置”窗口 ,但是您需要选择正确的配置才能启动。

Or you can assign a true shortcut to a specific launch configuration , which is closer to what you are after, but that need an additional plugin (" Practically Macro ") 或者您可以为特定的启动配置分配一个真正的快捷方式,这个快捷方式更接近您所追求的,但是需要一个额外的插件(“ 实际宏 ”)

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

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