Wednesday 16 July 2014

Debugging java code in eclipse

Debugging is referred as watching the source code and variables of the program during execution. The stop point or break point is specified in the code where the execution is paused by the debugger. Then you can use step over, step into commands to go to next statement for execution. In this tutorial we are going to use java debugger that comes in eclipse. The eclipse used for demonstration is eclipse juno. Eclipse has special perspective for debugging allowing investigation for variables or execution statements.

Step 1 : Create a java program

You might be familiar with writing programs in java.
  • Open eclipse
  • Start new java project
  • Write your java class

Step 2 : Adding breakpoints in your java program

To add a break point simply double click on the narrow margin in your code editor or right click on that and select toggle break point.


Once you have added break point to your code, you will see a blue solid circle just inline with the statement where break point was added. You can always toggle break point on or off.

Step 3 : Running the debugger

Right click on your program -> debug as -> java application


This will start running your program in debugger perspective. You can use step over or into commands jump to next statements or previous.


You must have to specify break points in order to watch your code, if you don't then program will executed as it should be.

No comments:

Post a Comment