Java Chat Application (Client-Server)
A simple multi-client chat application built using Java Sockets and Swing GUI. It allows multiple clients to connect to a server and exchange messages in real-time. The application demonstrates core concepts of networking, threading, and GUI development in Java. Features
GUI-based client and server applications using Java Swing
Server accepts multiple clients concurrently using multi-threading
Real-time group chat with message broadcasting
Logs client connections and chat messages on the server
Clean and modular code architecture
💻 Technologies Used
• Java (JDK 8+)
• Java Swing for GUI
• Java Sockets for networking
• Multithreading with Runnable
How to Run
Prerequisites:
• Java JDK installed
• Any Java IDE (e.g., IntelliJ IDEA, Eclipse) or terminal/command line
Step 1: Compile all files
javac Server.java Client.java ClientHandler.java
Step 2: Run the Server
java Server
A GUI window for the server will open. It listens on port 1234.
Step 3: Run the Client(s)
java Client
• Enter a username when prompted.
• A client window opens, allowing real-time messaging.
• Open multiple clients to simulate group chat.
Key Classes
Server.java
• Launches the server and GUI window
• Accepts client connections
• Creates a new ClientHandler for each client
Client.java
• GUI for the user to send/receive messages
• Connects to the server via socket
• Sends messages and listens for incoming messages on a separate thread
ClientHandler.java
• Handles each connected client on a separate thread
• Reads incoming messages and broadcasts them to all other clients
• Manages socket and stream cleanup
