Which is the better language to learn to do this? Java or HTML5?
Flash aka ActionScript.
Client-side Java is either abandoned, obsolete or deprecated and either lacks even the most basic facilities (such as any meaningful sound/media capabilities) or is difficult to present seamlessly (security warnings aplenty). In addition, it's poorly supported in practice. Despite cited 60% install base about a third of PC users that will be able to run the actual applets without problems. Browsers on other OSes are not very supportive of Java.
For more practical issues, just dealing with bitmaps will be an incredible pain compared to one-line approach built into Flash.
Yes, it can be done. Yes, it has been done. Both, Java and HTML5. But just because chainsaws can be juggled, it doesn't mean it's a good idea or a good starting point. Start with 3 rubber balls, there will be much less pain.
HTML5 for the chatroom[/quote]
HTML5 chatroom either needs to swallow the whole long-poll overhead and complications on both, client and server, or use "true" HTML5 web sockets which are barely supported on a handful of browsers, but are barely adopted. Either way, it requires considerably more complication on both, client and server than needed.
It's good for experimentation or if one uses a third-party solution, but not worth the effort to roll custom version.