IM++: The Java Messaging Program

Developed by Charles Duan
Summer 2001

What is IM++?

IM++ is a program which works very much like AOL's popular Instant Messenger program. However, unlike Instant Messenger, IM++ is designed to be a flexible, powerful, and, most importantly, highly extensible piece of software, so that future developers may easily improve and add functionality to the basic program.


All files, including source: files31.jar
Account creation program: acct31.jar

To run either, just execute the jar file. To run the server, execute the following line:

java -classpath files31.jar
with appropriate parameters.

Running the Server

IM++ is run through a server application to which clients may connect. The fully-qualified name of the server class is:
The execution of the class requires at least one argument, which is the port on which the server will listen for clients. A second parameter may also be specified, which is a file name. Upon shutting down the server, the database of users will be written to the specified file, and upon starting the server, the file will be read (if it exists) for user information.

Adding a Client to the Server

Before a client may use the server, the client must register with the server first. This is done by executing the following class:
The program will prompt for a new user name and a password. It will also request a server name and port number. The server name is the identifying name for the computer on which the server is running (generally an IP or DNS name), and the port number is the number which was specified as the parameter for the server. Once the user name has been accepted, the user may log in to the server.

User names are not case-sensitive, but they do include spaces and punctuation, so that " " would be a valid user name.

Starting a Client

A client session may be initiated simply by executing the client class:
With JDK 1.3 and above, the jar file (below) may be executed directly to run this class (in Windows, double-click the jar file).

Upon execution, a dialog will pop up, requesting a user name and a password, as well as a server name and port. The server and port fields should contain the name of the server and the specified port number (the same as those specified in creating the account).

Once the server accepts the user name, the user may proceed to use the program, as described below.

Basic Use of the Message Window

The client program runs in two windows, a message window and a buddy list. The message window is divided into two parts: the top half is a tabbed pane and a text area, and the lower half contains a selection box, a "Send" button, and a smaller text area.

The top half is the "message area" for the program. Each tab (except the first) contains the name of a user. Clicking on the tab will bring up a transcript of the conversation with that user. If another user sends a message while his/her tab is not selected, the tab for that user will turn red to indicate that a new message was received.

The lower half is used for sending messages to other users. To send a message to another user, first select the user's tab. Then enter the message to send to that user in the lower text area, and press the "Send" button. The message will be displayed in the above text area and sent to the other user.

To create a new tab (i.e., to initiate a conversation with another user), select the first tab, marked "Create User," and enter the user's name in the lower text field and press the "Send" button.

The combo box to the left of the "Send" button has the same functionality as the tabbed pane; selecting a user on the combo box will pop that user's tab to the front. This is useful for quickly flipping through all the session tabs at once.

The proportion of the window for the message area and the message entry box can be adjusted by sliding the divider between them up and down.

Use of the Buddy List

The buddy list appears in a separate window, usually to the left of the message window. It may be closed and reopened through the View menu. Buddies may be added and removed by right-clicking on the buddy list. Additionally, double-clicking on a buddy in the buddy list will create a new session with that user (if it does not exist) and flip it to the top.

Buddies may also be added using the proper server commands, but that method will not update the appearance of the buddy list.

Basic Server Use

The server is manipulated through "server commands," which are specific messages sent to the server. They are sent to the user named "Server" like normal messages. Those commands are documented in the source code; you can use javadoc to retrieve them. Additionally, there are several special commands which may be used by only a user named "Superuser." The most important of these include load, which installs a new command (see the above link for specific information), setpwd, which changes a user's password, and shutdown, which causes the server to sever all connections, save its state (if requested to do so), and terminate.

Next: A description of the general architecture