View RSS Feed

Eclipse IDE

Eclipse Debugging

Rate this Entry
by , 02-11-2012 at 03:08 PM (1125 Views)
Debugging a program is very important in programming. It helps you in find errors and saves lot of time. In the following steps, we will create and debug a Java Program.

1. Write a Java Program

Write a program that computes the factorial of a number n. This program should have an error and gives wrong output. We will debug this program to find the error.

2. Set Breakpoint

Name:  1.JPG
Views: 192
Size:  20.9 KB

Break Points

Breakpoint is used to stop or suspend program at breakpoint so that you can analyze the value of variables. To setup debugger, you must need to set one breakpoint. To setup a breakpoint, double click on left margin as shown in above image. It setups breakpoint at main method.

3. Start Debugger

Name:  1.JPG
Views: 79
Size:  14.8 KB


Start the program in debug mode. It will start execution but will stop at the specified breakpoint as show in above diagram.

4. Step Over and Watch Variables and Output

Step Over button as shown in the image helps you step thru your program. After each Step Over, you can examine the variables and values in Variable Panel. Also by keeping you cursor on any variable will show you its value. It simulates the actual program execution.

Name:  1.JPG
Views: 102
Size:  18.3 KB

Step Over and Watch Variables and Output

Submit "Eclipse Debugging" to Facebook Submit "Eclipse Debugging" to Digg Submit "Eclipse Debugging" to Submit "Eclipse Debugging" to StumbleUpon Submit "Eclipse Debugging" to Google