For some bizarre reason I've written a number of small, test bed style IM applications, using both J2EE and plain Java. The only reason I would recommend J2EE over plain java is if the IM application is going to be web-based, that is browser-based chat. With AJAX and J2EE you could write an awfully nice chat service. The other reason you might choose J2EE is if you wanted to use something like XMLRPC or SOAP for the back-end protocol.
My preference has been to use straight sockets coding (NIO would be key on the server if you want to scale fairly large) and just have a Java process running to listen on a port. Then you can use a rich client (like Swing or SWT) for the IM client and have something that's more like a AIM or IRC chat.
Writing an IM type application is surprisingly challenging. You'll learn a lot. Good luck.
(If you want to look at one of the IM programs I've written for some inspiration, check out the code here: http://nule.org/wp/?page_id=74
and a screenshot of some clients chatting here: http://nule.thot.us/public/messenjerworking.png
It's actually a working program, but I lost interest when the person I was developing it for adopted another solution. Maybe someone here will re-inspire me.)