I recently saw that there has been lots of discussion on the custom rest service legend sample posted on the code gallery in terms of getting the sample up and running successfully. If you have no clue on what I am talking about, here is the link.
This post should help you get the sample running in no time (almost):
I am using Eclipse (screen-shots show version 3.4/Ganymede, 3.3/Europa should work as well) as my IDE and ArcGIS Server 9.3.1 Java ADF libraries.
1. Download the sample on to the disk: