Simple program Debugging using eclipse
Simple Fibonacci program:
package com.gk; public class FibonacciNumber { public static void main(String[] args) { int n=5,i,f0=1,f1=1,f2=0; for (i=1;i<=n;i++) { f2=f0+f1; f0=f1; f1=f2; f2=f0; System.out.println(f2); } } }
In the above program is successfully compile and prints the output as get in Console below
Output: 1 2 3 5 8
But before going to run this program the compiler checks the program is Syntactically and Symmetrical. The program is correct now run the program it takes the responsibility for JVM. The JVM will be run the program if the program is correct otherwise it throws the ‘Runtime Error’s or Exceptions’. To identify which type of Errors are getting in the Eclipse easy to solve the problem. To debug the program.
How to use the Debugging in Eclipse:
In Eclipse Extra feature is easy to debug the program. Double click on before statement. That is debugging point start to there as shown below
Now Right click on Run the Debug As option in theat Click on the Java Application shown below
Now you get a window like below click on the Yes button
Now Debugging is Started shows the step by step process storing values.
To move the next statement to debug press F6 button the control will be goes to the next statement. Pervious statement will be executed.
To move continues the debugging statements is executed.(press F6)
finally it debug the end point shows the output in Console shown below.