简体   繁体   English

Netbeans:如何逐步运行项目,以便查看逻辑错误在哪里?

[英]Netbeans: How do i run a project step by step so I can see where the logical error is?

I remember one of my tutors in University, running a project in Netbeans step by step, manually going through each step of the run time. 我记得我在大学的一位导师,他一步一步地在Netbeans中运行一个项目,手动完成了运行时的每一步。 Anyone have any idea how to do this? 有人知道如何执行此操作吗? I can't seem to figure it out. 我似乎无法弄清楚。

First you need to add breakpoints to your code by clicking on the line number like shown on the image below: 首先,您需要通过单击行号将断点添加到代码中,如下图所示:

在此处输入图片说明

Once you do that you can start you application in debug mode. 完成后,您可以在调试模式下启动应用程序。 You do this by clicking the debug button. 通过单击调试按钮来执行此操作。 And the your program will stop at specified debug points. 并且您的程序将在指定的调试点停止。 Here is the image of the debug button: 这是调试按钮的图像:

在此处输入图片说明

You can get more information here: https://netbeans.org/features/java/debugger.html 您可以在此处获取更多信息: https : //netbeans.org/features/java/debugger.html

Once you place a breakpoint you can continue from there either step by step or even using commands to get into a function and move to the code executed by it. 放置断点后,您可以从那里继续操作,甚至可以使用命令进入某个函数并继续执行该函数执行的代码。 You can see a list of your options in the Debug menu: 您可以在“调试”菜单中查看选项列表:

F8 - Step Over F8-越过

F7 - Step Into F7-进入

Ctrl + F7 - Step out Ctrl + F7-退出

And so forth. 依此类推。 This way you can navigate step by step without the need to have a breakpoint at each step. 这样,您可以逐步导航,而无需在每个步骤都设置断点。

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

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