Vous êtes sur la page 1sur 21

Java Remote Desktop Control

Actual Client Desktop

Screen shot client side

Remote Image of the Connected Client Desktop

Screen shot server side


SVERIs College of Engg. (Poly), Pandharpur1

Java Remote Desktop Control

REQUIRMENTS SPECIFICATION

4.1 HARDWARE SPECIFICATION


Processor RAM VDU Hard Disk : Intel Pentium compatible or above : 4MB free space : VGA/ S V G A : 50 MB free space

4.2 SOFTWARE SPECIFICATION


Operating System Programming language : MS DOS / Windows 95/ Linux : Java2 ( JDK 1.2)

SVERIs College of Engg. (Poly), Pandharpur2

Java Remote Desktop Control

DESIGN SPECIFICATION
The proposed system is going to be developed using Java 2.java is platform independent. Thus it will run under any operating system like Windows or Linux. The system explorer is mainly concentrated on the development of an application that is used to explore computers in a network. The main part of the application is a GUI that is used to browse other machines in the network. The GUI should be developed using Java Swing. The system should be modularized into a client part and a server part so that each part could be run separately. The server part should acts as the file server for the local client as well as the remote server. The client part should provide a GUI for easy user interaction. All request from the client are passed to the local server only. Requests to the remote server are forwarded by the local sever.

SVERIs College of Engg. (Poly), Pandharpur3

Java Remote Desktop Control

Background
One of the biggest challenges in this project is finding a way to move the mouse pointer, simulate key stroke and capture the screen. After spending some time I found a great class, Robot class that does all that I need. In addition, using serialization to send screenshots from client to server and to send server events like mouse move, key press, key release helped me a lot to write clean and simple code instead of sending images and events in raw data format over the network.

Robot Class Methods


mouseMove - Moves the mouse pointer to a set of specified absolute screen coordinates given in pixels mousePress - Presses one of the buttons on the mouse mouseRelease - Releases one of the buttons on the mouse keyPress - Presses a specified key on the keyboard keyRelease - Releases specified key on the keyboard createScreenCapture - Takes a screenshot

SVERIs College of Engg. (Poly), Pandharpur4

Java Remote Desktop Control

Program Parts
1. RemoteServer
This is the server part which waits for clients connections and per each connected client, a new frame appears showing the current client screen. When you move the mouse over the frame, this results in moving the mouse at the client side. The same happens when you right/left click mouse button or type a key while the frame is in focus.

2. RemoteClient
This the client side, its core function is sending a screen shot of the client's desktop every predefined amount of time. Also it receives server commands such as "move the mouse command", then executes the command at the client's PC.

SVERIs College of Engg. (Poly), Pandharpur5

Java Remote Desktop Control

Using the Code


In order to run the program, you need to download RemoteServer_source.zip and RemoteClient_source.zip on two different PCs, then extract them. In one of the PCs say PC1, run RemoteServer.jar which is located under dist folder using the following command: Collapse | Copy Code
>>java -jar RemoteServer.jar

You will be asked to enter port number for the server to listen at, enter any port number above 1024, for example 5000. On the other PC say PC2, execute RemoteClient.jar using the following command: Collapse | Copy Code
>>java -jar RemoteClient.jar

You will be asked to enter server IP, enter IP address of PC1, then you will be asked to enter port number, enter the same port you entered above, e.g. 5000. Now, in PC1 you have full control over PC2 including moving the mouse, clicking the mouse, keys stroking, viewing PC2 desktop, etc.

SVERIs College of Engg. (Poly), Pandharpur6

Java Remote Desktop Control

Coding Structure
RemoteServer
ServerInitiator Class This is the entry class which listens to server port and wait for clients connections. Also, it creates an essential part of the program GUI. ClientHandler Class Per each connected client, there is an object of this class. It shows an InternalFrameper client and it receives clients' screen dimension. ClientScreenReciever Class Receives captured screen from the client, then displays it. ClientCommandsSender Class It listens to the server commands, then sends them to the client. Server commands include mouse move, key stroke, mouse click, etc. EnumCommands Class Defines constants which are used to represent server commands.

SVERIs College of Engg. (Poly), Pandharpur7

Java Remote Desktop Control

RemoteClient
ClientInitiator Class This is the entry class that starts the client instance. It establishes connection to the server and creates the client GUI. ScreenSpyer Class Captures screen periodically and sends them to the server. ServerDelegate Class Receives server commands and executes them in the client PC. EnumCommands Class Defines constants which are used to represent server commands.

SVERIs College of Engg. (Poly), Pandharpur8

Java Remote Desktop Control

Code Snippets
1) RemoteClient
Connect to Server
System.out.println("Connecting to server .........."); socket = new Socket(ip, port); System.out.println("Connection Established.");

Capture Desktop Screen then Send it to the Server Periodically In ScreenSpyerclass, Screen is captured using createScreenCapture method in Robot class and it accepts a Rectangle object which carries screen dimension. If we try to send image object directly using serialization, it will fail because it does not implement Serializableinterface. That is why we have to wrap it using the ImageIconclass as shown below:
while(continueLoop){ //Capture screen BufferedImage image = robot.createScreenCapture(rectangle); /* I have to wrap BufferedImage with ImageIcon because * BufferedImage class does not implement Serializable interface */ ImageIconimageIcon = new ImageIcon(image); //Send captured screen to the server try { System.out.println("before sending image"); oos.writeObject(imageIcon); oos.reset(); //Clear ObjectOutputStream cache System.out.println("New screenshot sent"); } catch (IOException ex) { ex.printStackTrace(); } //wait for 100ms to reduce network traffic try{ Thread.sleep(100); }catch(InterruptedException e){ e.printStackTrace(); } }

Receive Server Events then call Robot Class Methods to Execute these Events
while(continueLoop){ //receive commands and respond accordingly System.out.println("Waiting for command"); int command = scanner.nextInt(); System.out.println("New command: " + command); switch(command){ case -1: robot.mousePress(scanner.nextInt()); break;

SVERIs College of Engg. (Poly), Pandharpur9

Java Remote Desktop Control

case -2: robot.mouseRelease(scanner.nextInt()); break; case -3: robot.keyPress(scanner.nextInt()); break; case -4: robot.keyRelease(scanner.nextInt()); break; case -5: robot.mouseMove(scanner.nextInt(), scanner.nextInt()); break; } }

SVERIs College of Engg. (Poly), Pandharpur10

Java Remote Desktop Control

2) RemoteServer
Wait for Clients Connections
//Listen to server port and accept clients connections while(true){ Socket client = sc.accept(); System.out.println("New client Connected to the server"); //Per each client create a ClientHandler newClientHandler(client,desktop); }

Receive Client Desktop Screenshots and Display them


while(continueLoop){ //Receive client screenshot and resize it to the current panel size ImageIconimageIcon = (ImageIcon) cObjectInputStream.readObject(); System.out.println("New image received"); Image image = imageIcon.getImage(); image = image.getScaledInstance (cPanel.getWidth(),cPanel.getHeight(),Image.SCALE_FAST); //Draw the received screenshot Graphics graphics = cPanel.getGraphics(); graphics.drawImage(image, 0, 0, cPanel.getWidth(),cPanel.getHeight(),cPanel); }

Handle Mouse and Key Events then Send them to the Client Program to Simulate them In ClientCommandsSenderclass, when mouse is moved, x and y values are sent to the client but we have to take into consideration the size difference between clients' screen size and server's panel size, that is why we have to multiply by a certain factor as shown in the following code:
public void mouseMoved(MouseEvent e) { doublexScale = clientScreenDim.getWidth()/cPanel.getWidth(); System.out.println("xScale: " + xScale); doubleyScale = clientScreenDim.getHeight()/cPanel.getHeight(); System.out.println("yScale: " + yScale); System.out.println("Mouse Moved"); writer.println(EnumCommands.MOVE_MOUSE.getAbbrev()); writer.println((int)(e.getX() * xScale)); writer.println((int)(e.getY() * yScale)); writer.flush(); } public void mousePressed(MouseEvent e) { System.out.println("Mouse Pressed"); writer.println(EnumCommands.PRESS_MOUSE.getAbbrev()); int button = e.getButton(); intxButton = 16; if (button == 3) { xButton = 4; } writer.println(xButton); writer.flush(); }

SVERIs College of Engg. (Poly), Pandharpur11

Java Remote Desktop Control

public void mouseReleased(MouseEvent e) { System.out.println("Mouse Released"); writer.println(EnumCommands.RELEASE_MOUSE.getAbbrev()); int button = e.getButton(); intxButton = 16; if (button == 3) { xButton = 4; } writer.println(xButton); writer.flush(); }

public void keyPressed(KeyEvent e) { System.out.println("Key Pressed"); writer.println(EnumCommands.PRESS_KEY.getAbbrev()); writer.println(e.getKeyCode()); writer.flush(); } public void keyReleased(KeyEvent e) { System.out.println("Mouse Released"); writer.println(EnumCommands.RELEASE_KEY.getAbbrev()); writer.println(e.getKeyCode()); writer.flush(); }

SVERIs College of Engg. (Poly), Pandharpur12

Java Remote Desktop Control

FUTURE ENHANCEMENTS
The Technology is growing very fast and in the Networking environment the administrator had to control the whole thing. Remote system controlling has huge potential in the Internet-based and service-oriented architectures .To survive from the competition each system has to produce some modifications to it in the future. New features will provide the system a new fresh look, by which it can attract a lot of Administrators. Due to this reason it's necessary that the system need to be modified according to the users requirements. Some of the future enrichments are as follows > The utility at present meant for intranet environments and has a wide range of application areas like virtual classrooms > Next generation of this utility package is supposed on internet based applications > Further variations aim to include added capabilities such as controls and more user controls on Remote Machines

>

A request queue for the serverv to handle multiple simultaneous requests for the same file

>

Compressing the file before sending them to a requested system and decompressing on reception

SVERIs College of Engg. (Poly), Pandharpur13

Java Remote Desktop Control

EXISTING SYSTEM Ample options are there in now a day s operating systems it to execute applications at the remote end. The basic services used by these operating systems today promote executions of the applications at the remote end with just restricted access. PROBLEMS WITH THE EXISTING SYSTEM

> > > > >

Administrator is not having full control There is no provision to reboot or shutdown Supports only one remote command on the remote machine at the same time Never gets the feeling that we are using the remote machine We cannot capture the remote systems Desktop

2.3 ADVANTAGES AND DISADVANTAGES OF THE EXISTING SYSTEM

Utilities like Telnet and remote control programs like Symantec's PC anywhere let you execute programs on remote systems, but they can be a pain to set up and require that you install client software on the remote systems that you wish to access. By using this users can save time by accessing data from remote systems. But using this all the users are not able to access the desktop of the remote machine The user will never get the feeling that they are working in the remote machine. Other problems areAdministrator is not having full control over the systems in the LAN. There is no provision to shutdown or reboot remote system. There is no way to use the processor of the remote machine directly

SVERIs College of Engg. (Poly), Pandharpur14

Java Remote Desktop Control

CHAPTER 1

1.1 INTRODUCTION
This program allows any computer to control other PCs remotely Remote DesktopControlleris a client-server software package allowing remote network access to graphical desktop. This software enables you to get a view of the remote machine desktop and thus control it with your local mouse and keyboard. It can be used to perform remote system control and Administration tasks in Unix, Windows and other assorted network environments. When the connection between a client and a server is first established, the server begins by requesting from the client , which typically results in the user being prompted for IP addressthe client end. The server and client then exchange messages to negotiate desktop size and frame size.

Fig. 1 Remote client and server connection

SVERIs College of Engg. (Poly), Pandharpur15

Java Remote Desktop Control Sr. No. Item 1 Item 2 Item 3

Table. 1 Name of Table (11-Italic)

SVERIs College of Engg. (Poly), Pandharpur16

Java Remote Desktop Control

Conclusion
Java Remote Desktop (jrdesktop) is an open source software for viewing and/or controlling a distance PC. Besides then screenshots, keyboard and mouse events transfer, jrdesktop includes many additional features (like: file transfer, data compression, color conversion, ...). jrdesktop uses RMI (Remote Method Invocation) with SSL/TLS to establish a secured connection between the viewer and the server. Java Remote Desktop (jrdesktop) is intended to run across different platforms (based on JVM).

SVERIs College of Engg. (Poly), Pandharpur17

Java Remote Desktop Control

A Project Report On Java Remote Desktop Control


Submitted in partial fulfillment of the requirements for the award of the degree

OF
DIPLOMA IN COMPUTER ENGINEERING By

Mr. DarshanDhanrajPurohit Mr. VinayVijaykumarMaslekar Mr. Amar Mohan Vasekar Mr. AmolSatyavanBandgar UNDER THE GUIDANCE OF Prof. Prashant S Bhandare

SVERIs College of Engg. (Poly), Pandharpur18

Java Remote Desktop Control

DEPARTMENT OF COMPUTER ENGINEERING


SHRI VITHAL EDUCATION & RESEARCH INSTITUTES

COLLEGE OF ENGINEERING (POLYTECHINIC), PANDHARPUR.

CERTIFICATE
The Project report entitled Java Remote Desktop Control submitted by

Mr. DarshanDhanrajPurohit Mr. VinayVijaykumarMaslekar Mr. Amar Mohan Vasekar Mr. AmolSatyavanBandgar
is approved for Diploma in Computer Engineering from SVERISs College of Engineering (Polytechnic), Pandharpur.

Name of Guide (Prof. Prashant S Bhandare) Department of Computer Engineering

Name Of Project Co-ordinator (Prof S. S. Kadganchi) Department of Computer Engineering

Prof. Kawale S. M. (Head of Department) Department of Computer Engineering

Prof. Misal N.D. (Principal)

Name of External Examiner - ________________________ Sign of External Examiner - __________________________

SVERIs College of Engg. (Poly), Pandharpur19

Java Remote Desktop Control

Date

Place :Pandharpur

ACKNOWLEDGEMENT

I take this opportunity to express my sincere thanks and deep sence of gratitude to my guide ,Prof. P. S. Bhandare for his constant support ,motivation, valuable guidance and immense help. During the entire course of this week. Without his\her constant encouragement, timely advice and valuable discussion, it would have been difficult in completing this work. I would also like to acknowledge Computer Engineering Department who provided me the facilities for completion of the project. I am thankful to him for sharing his\her experience in the research field with me and providing constant motivation during entire project. I would also like to express my gratitude to all my friends who helped me a lot for completion of my midterm project work.

Mr. VinayVijaykumarMaslekar

SVERIs College of Engg. (Poly), Pandharpur20

Java Remote Desktop Control

Features
Communication through RMI Multiple Sessions Multiple User Interfaces Multihomed Server Authentication Encryption File Transfer Clipboard Transfer Color Quality Image Quality Data Compression Screen Functions Control Functions Connection Details Remote Host Properties

Basic Edition

X X X X X X X X X X X X

SVERIs College of Engg. (Poly), Pandharpur21

Vous aimerez peut-être aussi