Pages Navigation Menu

Coding is much easier than you think

Debugging java application in Eclipse

 
Debugging In Java
 
In this post let us learn about come of commonly used java debugging tips in eclipse.
 
1) Use conditional breakpoint
 
Eclipse allows you to setup conditional break point for debugging, which is a breakpoint with condition and your thread will only stop at specified line if condition matches instead of just stopping on that line like in case of line breakpoint. To setup a conditional breakpoint just double click on any line where you want to setup a breakpoint and then right click –> properties and then insert the condition. Now program will only stop when that particular condition is true.

 

1

 
2

 
2) Use Exception breakpoint
 
You can setup Exception breakpoint based on java exception like ArrayIndexOutOfBoundException or NullPointerException. You can setup Exception breakpoint from breakpoint window and your program will stop when exception occurs.

 

ecplise debug mode

 

3 ) Inspect and Watch
 
These are two menu options which is used to see the value of expression during debugging java program. To do, just select the statement, right click and inspect and it will show you the value of that statement at debugging time. You can also put watch on that condition, now its value will appear on watch window.

 
4) Step over, Step Into
 
These are simply great debugging options available in any Java IDE, extremely useful if you are debugging multi-threaded application and want to navigate step by step.
 
5) Suspending and resuming thread
 
You can suspend and resume any thread while debugging java program from debug window. Just right click on any thread and select either suspends or resume.
 

About Mohaideen Jamil