Breakpoints and step by step debug in Java?

萝らか妹 提交于 2019-12-04 17:37:00

Most IDEs have debugging functionality built in.

In Netbeans, you can easily add/remove a break point by simply clicking the line number on right side of the source editor (you can also do via the editor popup menu)

You start the debugger through F5 (ShiftF5 for debug the current file) or via the debug icon on the toolbar

You can use F8 to step over the command/method call, F7 to step into a method. You can resume running the program using F5 while the debugger is running.

See Debugger and Profiler and Using the Visual Debugger in NetBeans IDE for more details

Finding how to do this in your IDE is pretty easy, see the other answers.

What is a bit more difficult is debugging an external (and/or) remote Java program in your IDE. Here it is how to do that with Eclipse: http://www.ibm.com/developerworks/library/os-eclipse-javadebug/. I guess other IDEs are similar. If you test via Maven/Surefire, you have a simple flag to do the same: http://maven.apache.org/surefire/maven-surefire-plugin/examples/debugging.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!