Click here to Skip to main content
12,746,572 members (30,830 online)
Click here to Skip to main content
Add your own
alternative version


117 bookmarked
Posted 17 Jan 2003

Talk2Me: Java instant messenger

, 3 Feb 2004 CPOL
Rate this:
Please Sign up or sign in to vote.
A near to perfect clone of the very popular Yahoo messenger. Purely written in Java and SWING, this messenger also uses the capabilities of JNI and JAWT to provide some features.

Sample Image - Talk2Me.jpg


What I am trying to introduce here is a full fledged Java Instant messenger, which has all the features supplied by commercial messengers like Yahoo or MSN. Although it cannot compared to be in par with those messengers, it is an attempt by me to learn Advanced Java and JNI concepts. The challenges I faced here were often overcome by referring to numerous sites, which nearly zeroes in or completely solved the issues I faced at that point of time. It improved my learning curve and also believe would do the same to you too. Ofcourse, there are some bugs and glitches, which I hope you would excuse. Thanks to anyone who takes the pain to report them or even suggest better way of doing things to me.

System Requirements

Window/WinNT/Solaris(To run the chat server)
Windows/WINNT (For running the chat client)
JDK Ver1.3 or higher(Although I havent tested with lower versions of that)

Challenges faced

1. Building the Server and Client framework code. The Server and Client use TCP sockets to communicate and a MESSAGE java object is passed across the server-clients. MESSAGE object is serialized and sent as a bytes through the TCP socket.
2. Building the SWING component. The Client bears all the complexities of java.Swing and puts few of the Swing components to the rubber test.The Server is a purely console based client as oppposed to Client. The Client uses Swing components extensively, the following are worth a mention.

Userlist - JTree whose L&F is similar to that of YAHOO's,which is updated on Client login,logout and status change.
ChatDialog - JFrame with JTextArea for typing a message and JEditorPane for displaying received messages. The reason why I chose JEditorPane is the ability to display HTML text. This helped me to easily add smileys and other HTML tags like FONT,IMG etc. Try all the YAHOO smileys here like :), >:), :)) etc and see the results.
ConferenceDialog - Similiar to ChatDialog and has a JList component in addition, to display the available users list.
JWindow - To display a splash screen. The picture was of course drawn by me.
System Tray Icon - To minimize the chat to the System tray was one of the primary features of an instant messenger. This was achieved using a JAWT call. The following of code complete with source is available in the following site, kudos to its creator.[^]
Flashing Window - Was achieved through a JNI call, which calls the Win API all FlashWindow(HWND,BOOLEAN) and a javax.swing.Timer to flash the window.

Steps to run

1. Unzip the contents of the zip to a folder. Make sure you have the following files in that directory.

2. Go the directory and run the server first. The command is,
java -classpath Talk2Me.jar Server
(To run the server doesn't need dll's and Server can run in any m/c WIN/SOLARIS provided it has JDK installed)

3. Now start the Client.
javaw -jar Talk2Me.jar (WINDOWS only)
On most machines, just double clicking the JAR would invoke the program)

4. Give any username and password and make sure you give the right Server IP where the server is running, in the Login dialog. It can be valid names like localhost,,


I wrote this messenger purely to serve as a knowledge base to other programmers. Please refrain from using this messenger for commercial purposes or whatsoever. Anyone who wishes to modify the code to suit their own requirements, please seek my consent before doing so. Please make sure that you mail me the exact purpose why you want to modify the code.

That's it folks. I've tried my best to make my code understandable and ofcourse there is always more than one way to do anything and it would be helpful If you could suggest me a better way of doing things. Your comments and feedback are always welcome.

Thanks and Happy messaging.

Alfred Jayaprakash


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Web Developer
India India
Currently in Chennai, India, working as a Developer for the last 4 years. A MFC/VC++ fanatic who actually lacks professional experience in the same. Worked to the hearts content in C,C++,Perl,Java,J2EE and C# all web based technologies. Also loves Dancing, Dramatics and painting and a self learnt Guitarist.

You may also be interested in...

Comments and Discussions

GeneralMy vote of 3 Pin
Member 1151265812-Jul-15 18:54
memberMember 1151265812-Jul-15 18:54 
QuestionNeed urgent help compiling the program? Pin
Anirban Chakraborty13-Aug-14 9:18
memberAnirban Chakraborty13-Aug-14 9:18 
Questiontook Pin
Member 108066469-May-14 6:50
memberMember 108066469-May-14 6:50 
Questionhow to invite friends Pin
suuhas17-Feb-14 4:25
membersuuhas17-Feb-14 4:25 
Questionwould like to modify your code Pin
Member 995398130-Mar-13 20:20
memberMember 995398130-Mar-13 20:20 
QuestionWants Documentation Pin
Kapil Gur11-Feb-13 4:18
memberKapil Gur11-Feb-13 4:18 
Questionwould like to modify your code Pin
qaniyare14-Jan-13 5:13
memberqaniyare14-Jan-13 5:13 
QuestionInterface modification Pin
Catherine128-Dec-12 20:55
memberCatherine128-Dec-12 20:55 
Questionplease help me Pin
howusuprosper13-Oct-12 21:48
memberhowusuprosper13-Oct-12 21:48 
Questionurgently need answer Pin
Member 876771411-Apr-12 0:09
memberMember 876771411-Apr-12 0:09 
QuestionPermission to use your code! Pin
BairacM9-Apr-12 8:50
memberBairacM9-Apr-12 8:50 
Generalcan I view your source code? Pin
gauj19-Mar-12 23:47
membergauj19-Mar-12 23:47 
QuestionDoes this chat application work on mac system? Pin
gauj19-Mar-12 23:40
membergauj19-Mar-12 23:40 
QuestionExtending your code Pin
Shivang desai22-Feb-12 11:52
memberShivang desai22-Feb-12 11:52 
QuestionSir, can we use and modify your codes for thesis purposes? Pin
john fritz1-Feb-12 6:29
memberjohn fritz1-Feb-12 6:29 
Questionlogin ? Pin
sunshinearies9-Jan-12 8:44
membersunshinearies9-Jan-12 8:44 
Questionlogin Pin
sunshinearies9-Jan-12 8:43
membersunshinearies9-Jan-12 8:43 
QuestionPermission to modify the code... Pin
jess67511-Nov-11 19:25
memberjess67511-Nov-11 19:25 
Questionhey Pin
mahi2529-Aug-11 5:43
membermahi2529-Aug-11 5:43 
Questionjawt missing Pin
pintoo8826-Aug-11 21:43
memberpintoo8826-Aug-11 21:43 
Questionuml diagram Pin
clario10-Jul-11 2:53
memberclario10-Jul-11 2:53 
GeneralTalk2Me JAVA Instant messenger Pin
RavindraReddy7925-May-11 8:14
memberRavindraReddy7925-May-11 8:14 
GeneralRe: Talk2Me JAVA Instant messenger Pin
pintoo8826-Aug-11 20:35
memberpintoo8826-Aug-11 20:35 
GeneralRe: Talk2Me JAVA Instant messenger Pin
daniel2012201229-Feb-12 12:06
memberdaniel2012201229-Feb-12 12:06 
GeneralI need help please Pin
Renon_Pal11-Apr-11 8:01
memberRenon_Pal11-Apr-11 8:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170215.1 | Last Updated 4 Feb 2004
Article Copyright 2003 by alfreds
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid