A real-time collaborative text editor built in Java that allows multiple users to edit documents simultaneously over a network connection. The application features live text synchronization, user typing indicators, and persistent document storage.
- Real-time Collaboration: Multiple users can edit the same document simultaneously
- Live Text Synchronization: Changes are instantly synchronized across all connected clients
- User Typing Indicators: Visual feedback showing when other users are typing
- Document Persistence: Automatic saving and loading of documents
- File Locking: Prevents conflicts during document operations
- User-friendly GUI: Intuitive Swing-based interface
- Client-Server Architecture: Robust networking with automatic connection handling
- Cross-platform Compatibility: Works on any Java-supported platform
- Programming Language: Java 8+
- Build Tool: Apache Maven
- GUI Framework: Java Swing
- Networking: Java Socket Programming (TCP)
- File Operations: Java NIO
- Concurrency: Java Threading and Executors
- Testing Framework: JUnit 4.11
collab-editor/
βββ src/
β βββ main/
β β βββ java/
β β βββ com/
β β βββ kareem/
β β βββ collab/
β β βββ App.java # Main application entry point
β β βββ networking/
β β β βββ Server.java # Server implementation
β β β βββ Client.java # Client implementation
β β β βββ ClientHandler.java # Server-side client handling
β β βββ ui/
β β β βββ Home.java # Main menu interface
β β β βββ TextEditor.java # Text editor interface
β β β βββ Ui.java # UI controller
β β βββ utils/
β β βββ DocumentManager.java # Document persistence
β β βββ FileUtils.java # File utilities
β βββ test/
β βββ java/
β βββ com/
β βββ kareem/
β βββ collab/
β βββ AppTest.java
βββ pom.xml # Maven configuration
βββ README.md
The application follows a client-server architecture with the following components:
- Listens on port 8080 for incoming client connections
- Manages document state and persistence
- Coordinates message broadcasting between clients
- Handles graceful shutdown and resource cleanup
- Connects to the server via TCP socket
- Sends text updates and receives real-time changes
- Handles message encoding/decoding for network transmission
- Manages connection lifecycle
- Server-side component managing individual client connections
- Processes incoming messages and broadcasts to other clients
- Maintains global document state
- Handles client join/leave events
- Swing-based GUI for text editing
- Real-time text synchronization with other clients
- User typing indicators and status updates
- Document change detection and network communication
- Persistent storage of document content
- Thread-safe file operations
- Automatic document loading on server startup
- Cleanup on application shutdown
The application uses a custom text-based protocol over TCP:
- TEXT Messages:
TEXT|username|isTyping|encodedContent
- Server Messages:
SERVER:
prefix for system notifications - Message Encoding: Special characters are escaped for safe transmission
- User types in editor β Document change detected
- Client sends update β Message encoded and sent to server
- Server receives message β Validates and updates global document state
- Server broadcasts β Sends update to all other connected clients
- Clients receive update β Decode message and update local editor
- Document saved β Server persists changes to disk
- Java 8 or higher
- Apache Maven 3.6+
- Network connectivity for multi-user collaboration
-
Clone the repository:
git clone <repository-url> cd collab-editor
-
Build the project:
mvn clean compile
-
Run tests:
mvn test
Start the application:
mvn exec:java -Dexec.mainClass="com.kareem.collab.App"
Or run the server separately:
mvn exec:java -Dexec.mainClass="com.kareem.collab.networking.Server"
Build executable JAR:
mvn package
Run the application:
java -jar target/collab-editor-1.0-SNAPSHOT.jar
-
Launch the application - The main menu will appear
-
Choose an option:
- "Create New Document": Opens a local text editor
- "Join Existing Document": Connects to a collaborative session
-
For collaborative editing:
- Ensure the server is running (port 8080)
- Click "Join Existing Document"
- Enter server address (default: localhost)
- Provide your username
- Start editing collaboratively!
- Default Port: 8080 (can be modified in
Server.java
) - Document Storage:
../../collab/temp/document.txt
- Connection Timeout: Configurable in client implementation
- Protocol: TCP
- Encoding: UTF-8
- Message Format: Custom text-based protocol
- Retry Logic: Built-in connection retry mechanism
# Clean and compile
mvn clean compile
# Run tests
mvn test
# Package application
mvn package
# Run with debugging
mvn exec:java -Dexec.mainClass="com.kareem.collab.App" -Dexec.args="-debug"
The project is compatible with any Java IDE:
- Eclipse: Import as Maven project
- IntelliJ IDEA: Open pom.xml as project
- VS Code: Open folder with Java extension pack
Run the test suite:
mvn test
For manual testing:
- Start the server:
java com.kareem.collab.networking.Server
- Launch multiple client instances
- Test real-time synchronization across clients
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Document path is relative and may need adjustment based on execution context
- Server requires manual startup for collaborative features
- Limited error handling for network interruptions
- User authentication and authorization
- Multiple document support
- Syntax highlighting for different file types
- Version control and change history
- Enhanced UI with modern look and feel
- WebSocket support for better real-time performance
- File import/export functionality
- Collaborative cursors and selections
Developed by Kareem - A collaborative text editing solution built with Java.
For support and questions:
- Create an issue in the repository
- Check existing issues for solutions
- Review the code documentation
Happy Collaborative Editing! π