Listen. When a guy is feeling down in the dumps, he may very well need to vent his feelings. Let him speak without butting in with advice or similar personal experiences. Show him that you are listening by saying phrases like "That must be tough" or "I can only imagine how painful that must feel." Listen patiently, and let your friend know you are there for him. Only offer advice if specifically asked.
Occupy your friend with activities to help keep his mind off his problems. Go for a hike, catch a movie or bring him along to a party. Don't persist if he refuses, but keep offers on the table in case he changes his mind.
Help your friend focus on the positive aspects of his life. Shift conversation to the good things in his life, whether they be friends, family or a job. Just let him know that he has a lot to live for, even though times may presently be trying.