You realize your first 3 sentences are redundant right?
In your topic post saying you want to create an instant messenger program in java would have been enough.
Now with out the nit picking...
That would be the same as creating a chat program. Check out this tutorial and the book How to program by Dietel and Dietel has a a very good case study on this in chapter 24 ( networking ).