Eclipse Zone is brought to you in partnership with:

chander is a DZone MVB and is not an employee of DZone and has posted 3 posts at DZone. View Full User Profile

Tips and Tricks for Debugging in Eclipse

  • submit to reddit
educational portal mbbs in india

In this article I will describe some tips and tricks for debugging your applications in Eclipse. I will cover the debug details formatter, breakpoints on classes only, as well as how to display all references and instances of a particular object or class.

Debug details formatter

 download music from mp3 search engine

When you debug your application you probably use the Variables view. One of the disadvantages is that you cannot see the data inside complex objects (unless they implement toString() method). Eclipse allows you to write your own formatter for displaying the content you are interested in. You can do it in the Eclipse preferences under Java->Debug->Detail Formatters.

Lets consider the following class:



When you want to check the value of the an object of this class during the debugging session you have to expand the object and inspect the value of all it’s parts. (see the picture below).


Let’s write our own formatter:

download Eclipse 34

And now in the Variables view we can see that the person object is shown differently:


If you want to see the formatter in the labels for variables you have to select the following option in the Eclipse preferences:


This allows you to see the result of your formatter in the value field of the Variables view:


I find this option very useful also for the standard classes (e.g. ArrayList), then instead of:


I can see:



Toggling class breakpoints on the class without the source code

When you want to stop the execution of your application in the moment when some of your class is loaded by the class loader you can use the class breakpoints (just toggle the breakpoint on the line when the declaration of the class begins). But what about the situation when you want the same behavior when a class, which you don’t have the sources for, is loaded? How to toggle such a breakpoint without the source code? You just have to go to the main menu and choose Run->Add Class Load Breakpoint…



Displaying all references of an object (new in Eclipse 3.3)

Sometimes it is worth to see all references of some object. How to achieve this? There are two ways of doing this. If you want to display references of the specific object, right click on the object in the Variables view and choose All References. The popup window will appear with all references. If you want to see all references of all available objects go to the menu in the Variables view and choose Java->Show References.

kjh hjkl


Displaying all instances of a class (new in Eclipse 3.3)

If you want to see all instances of a class just mark this class in the Java editor and choose All Instanced from the context menu.




Please visit Eclipseeducational portal , share your knowledge and get paid.


code.png12.67 KB
var_1.png12.87 KB
fiormatter.png32.62 KB
var_2.png30.92 KB
pref.png50.01 KB
var_3.png30.6 KB
var_4.png27.07 KB
var_5.png27.47 KB
menu.png3.68 KB
show_ref.png30.14 KB
show_ref2.png27.19 KB
all_instances_contextmenu.png2.26 KB
all_instances_popup.png2.72 KB
Published at DZone with permission of chander prakash, author and DZone MVB.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Gerald Preissler replied on Fri, 2008/10/17 - 8:52am

Hi Chander,

 nice article. One question:

 Can you explain how the classpath for a detail formatter is determined? I remember trying to define one that provided a readable string representation for a WS-Policy document (using Neethi) and I kept getting ClassNotFoundExceptions. Strange thing was that sometimes it worked and sometimes it did not.




Juan Ruz replied on Mon, 2008/12/01 - 5:40am

someone knows something about JIVE for debugging either forward or backwards?


Tom Close replied on Sat, 2009/10/17 - 8:56am

Hi Chandler, I realise this is a little late, but do you know if you can do something similar for the C/C++ CDT plugin? I am migrating my project over from Xcode and have found such formatters very useful. Cheers, Tom

Carla Brian replied on Sat, 2012/05/19 - 9:33am

This is really helpful. I am not that good in Eclipse and I am new with that programming language as well. This could be a good resources for learning. Thanks for sharing your tips. -Kummetz Korp LLC

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.