Debugging In NetBeans IDE18 April 2007
Efficient programs always need locating the bugs and fixing those. Basic meaning of debugging a program is to run through the code with the Interpreter. Debugging enables the user to see whether the path of execution is as per his expectations or same as the path meant for them and only through them. When a programmer says he has debugged the program, it means bugs has been worked out and bugs no longer exist.
For a Java programmer there are varieties of tools but if you are using an editor like NetBeans then it becomes quite easy for you to debug the program.
Here are the steps to be followed to debug a java program using NetBeans .
- The very first step in debugging is to load your application and open the java file that you wish to debug.
- Now in NetBeans we need to ensure we have the proper main class selected and we are passing required parameters in. To do this click on “ File ” – > “ projectname ” – > “ Properties ”.Click “ Run ” option .Following window will be appeared where you can fill name of main class which will be run.
- Now we can set breakpoint in the java code. Break point is a debugging mechanism that tells the program that when you reach this point you want to stop the program. Just go on the line where you want to set break point and then click on the bluish border on the left. This will mark a breakpoint on this line. Here is a snapshot after setting a breakpoint.
- Now you can start actually debugging the project. Don’t use normal run main project to debug as it will ignore all break points. So to debug click on “ Debug Main Project ”. It can be found in the “ Run ” menu or as a button on the tool bar.
- On the same menu you can see several options. Use as per your choice. Use F4, F7, ctrl+F7, Ctrl+F8 as per your choice.
- If you encounter any problem then terminate the process by going on “ Runtime ” tab and deleting relevant process under processes running in IDE.
Here select the main class you want to run/debug and press “ OK ”.
It will look like this: Debugging In NetBeans IDE