The Chat Application consists of two main components: the client and the server. The client is responsible for sending messages, and the server handles receiving and broadcasting these messages to other connected clients.
- Java Development Kit (JDK): Ensure that you have JDK installed on your system. You can download it from Oracle JDK or use OpenJDK.
- Open a terminal or command prompt.
- Navigate to the directory containing the server files.
- Compile the server code:
javac Server.java
- Run the server:
The server will start and wait for incoming client connections.
java Server
- Open a new terminal or command prompt.
- Navigate to the directory containing the client files.
- Compile the client code:
javac Client.java
- Run the client:
The client application window will appear.
java Client
- The client application window will display a chat interface with a text input field at the bottom.
- Enter your message in the text field.
- Click the "Send" button to send the message.
- The messages will be displayed in the chat window, including a timestamp.
-
Server Initialization: The server needs to be started before any clients connect. Ensure that the server is running when launching the client application.
-
Server Address: The client is configured to connect to the server at the address "127.0.0.1" (localhost) on port 6001. If the server is running on a different machine, modify the server address in the client code accordingly.
-
Icons: The client application uses image icons located in the "icons" directory. Ensure that the "icons" directory is present in the same directory as the client Java file.
- Click the close button on the client application window to exit the program. This will close the client connection to the server.
- If there are issues with connectivity, ensure that there are no firewall restrictions preventing communication on the specified port.
This Chat Application is a simple demonstration and may not be suitable for production use. It lacks security features and error handling mechanisms commonly found in robust chat applications.