View RSS Feed

My Java Tips

Eclipse Debugging

Rate this Entry
by , 11-04-2011 at 07:44 PM (1204 Views)
Following are Eclipse debugging features: Breakpoints, Step into, Step over, Step return, Step Filters, Watches, Run to line, Suspend/Resume/Terminate. You should know each of these for debugging your Java programs. I will try to introduce these in the next few posts.

We use breakpoints in our Java source to cause the thread of execution to suspend and return to the debugger. To set breakpoints in Eclipse, simply double-click the left margin.

Use ‘Step Into’, to execute single highlighted statement. If a statement contains call to method, then ‘Step Into’ steps into the method. In the debug perspective, F5 is used for ‘Step Into’.

‘Step Over’ also executes single highlighted statement but the difference is that if the statement contains method call, then the method is executed without stepping in to it. Use it if you do not want to go into a method while debugging. In the debug perspective, F6 is used for ‘Step Over.

F7 is the short key for ‘Step Return’. It simply returns to where method was called. Eclipse debugging provides ‘Step with filters’ which is a very useful debugging feature the. Go through Window > Preferences > Java > Debug > Step Filtering. Using this, we can specify which methods ‘Step Filter’ will execute and return from. Use this if you want to step only into methods of your choice.

Name:  stepfiltering.png
Views: 71
Size:  18.3 KB

Watches are used to view the value of a variable during program execution. Eclipse set watches automatically on variables in scope. In Eclipse Debug perspective, there is a variable window that shows the watched variables. A good thing is that Eclipse allows the users to change the value of variables dynamically during runtime. It’s a very powerful feature.

You will find Suspend/Resume/Terminate options while debugging. Suspend is used to pause the current thread of execution and this breaks into the debugger. Use resume to resume a suspended application. Terminate stops the program and debugging process

I hope this will help you debug your Java programs in a better way.

Happy debugging.

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

Tags: None Add / Edit Tags