Click here to Skip to main content
15,885,767 members
Articles / Desktop Programming / Swing
Article

Talk2Me: Java instant messenger

Rate me:
Please Sign up or sign in to vote.
4.70/5 (95 votes)
3 Feb 2004CPOL3 min read 963K   23K   120   345
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

Introduction

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.
http://jeans.studentenweb.org/java/trayicon/trayicon.html[^]
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.
Talk2Me.jar
TrayIcon12.dll
Client.dll


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, 127.0.0.1, 172.22.11.88...etc.

Note

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

License

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


Written By
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.

Comments and Discussions

 
GeneralMaking you Messanger P2P Pin
Member 16251992-Jan-05 12:24
Member 16251992-Jan-05 12:24 
GeneralRe: Making you Messanger P2P Pin
Alois -BSSA-5-Jan-05 4:59
Alois -BSSA-5-Jan-05 4:59 
Generalcannot load client.dll Pin
montysehra30-Dec-04 7:48
montysehra30-Dec-04 7:48 
GeneralNice App Pin
callmobius6-Nov-04 21:04
susscallmobius6-Nov-04 21:04 
Generaltrayicon12.dll Pin
rphadke2-Nov-04 22:38
rphadke2-Nov-04 22:38 
QuestionCompiling the files?? Pin
XCutionerXtreme15-Oct-04 8:13
XCutionerXtreme15-Oct-04 8:13 
AnswerRe: Compiling the files?? Pin
botboyin8-Feb-07 7:16
botboyin8-Feb-07 7:16 
GeneralRunning The Program Pin
Rebel63813-Oct-04 15:28
Rebel63813-Oct-04 15:28 
Generalto subject it as my academic project Pin
saranSuryah28-Sep-04 21:04
saranSuryah28-Sep-04 21:04 
Generalerror: cannot load main-class in Talk2Me.jar Pin
core_eye10-Sep-04 7:19
core_eye10-Sep-04 7:19 
GeneralNeed some help Pin
anurag_anu_200030-Aug-04 23:03
anurag_anu_200030-Aug-04 23:03 
GeneralCannot load Client.dll Pin
Femi Buroh30-Aug-04 7:06
Femi Buroh30-Aug-04 7:06 
GeneralRe: Cannot load Client.dll Pin
Member 14675774-Nov-04 6:27
Member 14675774-Nov-04 6:27 
GeneralGiving me the error in executing Talk2Me: Java instant Messenger Pin
Jinesh Sanghvi25-Aug-04 7:24
Jinesh Sanghvi25-Aug-04 7:24 
GeneralJava final Project Pin
pokerstar6-Jul-04 10:38
pokerstar6-Jul-04 10:38 
QuestionHow to compile dll Pin
ctjoumas1-Jul-04 6:00
ctjoumas1-Jul-04 6:00 
AnswerRe: How to compile dll Pin
ctjoumas19-Jul-04 1:42
ctjoumas19-Jul-04 1:42 
GeneralFlashWindow Pin
ctjoumas30-Jun-04 1:30
ctjoumas30-Jun-04 1:30 
GeneralRe: FlashWindow Pin
ctjoumas19-Jul-04 1:41
ctjoumas19-Jul-04 1:41 
GeneralA few Doubts Pin
Sivaram Sekar28-Jun-04 18:06
Sivaram Sekar28-Jun-04 18:06 
Generalmodify your codes Pin
nickee15-Jun-04 7:16
nickee15-Jun-04 7:16 
Generalplz support me Pin
manish45415-Jun-04 5:57
manish45415-Jun-04 5:57 
GeneralError During load Client.dll Pin
manish45415-Jun-04 5:49
manish45415-Jun-04 5:49 
GeneralRe: Help Help Help Me............. Pin
manish45417-Jun-04 23:16
manish45417-Jun-04 23:16 
Generalwhy you use dll's Pin
Member 10491533-Jun-04 5:57
Member 10491533-Jun-04 5:57 

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.