To test the Chat application:
Set the path of the bin directory of J2SDK by executing the following command at the command prompt:
set path=%path%;D:\j2sdk1.4.0_02\bin;
Set the classpath of the lib directory of J2SDK by executing the following command at the command prompt:
set classpath = %classpath%;d:\j2sdk1.4.0_02\lib;
Copy the ChatServer.java, UAServer_Socket.java, PRServer_Socket.java, AppendUserList.java, Msgbroadcast.java, and SocketCallback.java files to a folder on the server computer. On the command prompt, use the cd command to move to the folder where you have copied the Java files. Compile the files using the following javac command:
javac *.java
Copy the ChatLogin.java, ChatClient.java, CClient.java, and Messager.java files to a folder on the client computer. Compile the files using the following javac command:
javac *.java
Run the Chat application server using the following command at the command prompt:
java ChatServer
Run the Chat application login window using the following command at the command prompt:
java ChatLogin
The Chat Login window appears, as shown in Figure 2-2.
Specify the server IP address, user name , and password. Click the Connect button. The Chat Application - user1 window appears, as shown in Figure 2-4:
Figure 2-4: Welcome Message in the Chat Application - user1 Window
An Error dialog box appears, if the process to establish a connection between the client and the server fails, as shown in Figure 2-5:
Figure 2-5: The Error Dialog Box
Run the Chat application login window using the following command at the command prompt from another client computer:
java ChatLogin
The Chat Login window appears, as shown in Figure 2-2.
Specify the server IP address, user name, and password. Click the Connect button. The Chat Application - user2 window appears, as shown in Figure 2-6:
Figure 2-6: The Chat Application - user2 Window with List of Users
When user2 joins the chat session, a message, user2 has joined the chat session appears in the text pane of the user1 chat window, as shown in Figure 2-7:
Figure 2-7: The Chat Application - user1 Window with user2 in Chat Session
Type Hi all in the text box of the Chat application window of user1 and click the Send button. The message is broadcasted to all the users, as shown in Figure 2-8:
Figure 2-8: Receiving Message in the Chat Application - user2 Window
Figure 2-9 shows the broadcast message that appears in the user2 client window:
Figure 2-9: Receiving Message in the Chat Application - user2 Window
Type Hi user2! in the text box of the user1 Chat application window, select user2 from the User List, and click the Private Message button. The message is sent to the user2 only, as shown in Figure 2-10:
Figure 2-10: Receiving Message in the Chat Application - user1 Window
Figure 2-11 shows the private message that appears in the user2 client window:
Figure 2-11: Private Message in the Chat Application - user2 Window
Click the Logout button of the Chat Application - user2 window. A Confirm dialog box appears, as shown in Figure 2-12:
Figure 2-12: The Confirm Dialog Box
Click Yes on the Confirm dialog box. A message, user2 has left the chat session appears in the text pane of all the chat users, as shown in Figure 2-13:
Figure 2-13: The Chat Application - user1 Window