The "Remote Desktop" project allows users to remotely control another computer. It consists of two main components: a Client and a Server. The Client application allows the user to specify the server's IP address and connect to it, while the Server is responsible for managing connections and sharing the screen, cursor, and keyboard events.
The client app is built with Java Swing for the graphical user interface, while the server app handles the backend tasks of capturing the screen, processing input events, and sending the data over the network.
This project is perfect for applications like remote support, screen sharing, or remote administration.
The architecture consists of two major components:
- Purpose: The client application connects to the server, sends user input (mouse and keyboard events), and displays the server's screen.
- Main Features:
- Control Panel: Allows users to input the server IP address and connect.
- Network Communication: Connects to the server via TCP sockets for real-time communication.
- Screen Display: Displays the server's screen (video stream) using a custom
ScreenPanel
. - Mouse and Keyboard Input: Captures user input (mouse movements, clicks, and keyboard presses) and sends it to the server.
Flow:
- The user enters the server IP in the control panel.
- The client connects to the server and starts receiving the screen data.
- The user can interact with the remote machine using mouse and keyboard inputs.
- Purpose: The server handles connections from multiple clients, captures the screen, and transmits the screen data over the network.
- Main Features:
- Screen Capture: Captures the desktop screen and encodes it for transmission.
- Mouse and Keyboard Event Handling: Listens for mouse and keyboard input events from clients and processes them on the remote machine.
- Compression and Streaming: Compresses the captured screen to reduce latency and sends it to the client.
Flow:
- The server listens for incoming client connections.
- Once connected, it starts sending the screen data and handling input events from the client.
- The client and server communicate over TCP sockets:
- The screen data is transmitted as compressed image frames.
- Mouse movements and clicks, as well as keyboard inputs, are sent from the client to the server for execution.
Follow these steps to set up and run the project locally.
- Java Development Kit (JDK) 8 or above
- Maven (optional, if you wish to build with Maven)
- IDE such as IntelliJ IDEA or Eclipse
git clone https://github.com/yourusername/remote-desktop.git
cd remote-desktop
If you are using Maven, run the following command:
mvn clean install
Alternatively, you can build the project manually by compiling the Java files.
- Navigate to the
server
folder. - Compile and run the server:
javac Server.java
java Server
The server will start and begin listening for client connections.
- Navigate to the
client
folder. - Compile and run the client:
javac NetworkScreenClient.java
java NetworkScreenClient
- In the client window, input the server's IP address (e.g.,
localhost
or the server's actual IP address). - Click Connect to establish the connection. The client should begin displaying the server's screen.
Once the connection is established:
- The client will display the server's screen.
- You can control the remote system by moving the mouse and typing on the keyboard.
- The server will receive the mouse and keyboard events and respond accordingly.
/remote-desktop
│
├── client/
│ ├── NetworkScreenClient.java # Client app that connects to the server and displays the screen.
│ └── ScreenPanel.java # Panel for displaying the remote screen and capturing input events.
│
└── server/
├── JNAScreenshot.java # Captures the screen and sends image data to clients.
└── NetworkScreenServer.java # Handles keyboard and mouse input from clients.
Planning to optimize it via Executors Service and Compression mechanisms for low latency.