Remote Desktop
Remote Desktop
Remote Desktop
INTRODUCTION
2
LIVE DESKTOP
3
LIVE DESKTOP
SYSTEM ANALYSIS
&
SOFTWARE
REQUIREMENT
SPECIFICATION
4
LIVE DESKTOP
5
LIVE DESKTOP
2.2.3Operational Feasibility:
6
LIVE DESKTOP
The process is order and more nebulous of the two, deals with
understand the problem, the goal and constraints.
7
LIVE DESKTOP
SOFTWARE SPECIFICATIONS:
8
LIVE DESKTOP
HARDWARE SPECIFICATIONS:
PROCESSOR : PENTIUM-4
RAM : 256 MB.(MINIMUM)
HARD DISK : 20GB (MINIMUM)
VDU : SVGA COLOR
MONITOR
KEY BOARD : 104 STANDARDS
LAN : ENABLED
9
LIVE DESKTOP
SYSTEM DESIGN
10
LIVE DESKTOP
1.Practicality
2.Efficiency
3.Cost
4.Flexibility
5. Security
11
LIVE DESKTOP
priviliges
process management
Figure 1
12
LIVE DESKTOP
IMPLEMENTATION
13
LIVE DESKTOP
14
LIVE DESKTOP
16
LIVE DESKTOP
17
LIVE DESKTOP
• Multithreaded
• Architectural-neutral
• High performance
• Distributed
• Dynamic
18
LIVE DESKTOP
19
LIVE DESKTOP
20
LIVE DESKTOP
own data type? Perhaps you want to work with complex numbers,
or two dimensional coordinates, or dates—quantities the built-in
data types don’t handle easily. Being able to create your own types
is called extensibility; you can extend the capabilities of the
language. Traditional languages are not usually extensible.
Without unnatural convolutions, you can’t bundle together both X
and Y coordinates into a single variable called Point, and then add
and subtract values of this type. The result is that traditional
programs are more complex to write and maintain.
21
LIVE DESKTOP
4.9 Classes:-
In OOP we say that objects are members of classes. What
does this mean? Let’s look at an analogy. Almost all computer
languages have built-in data types. For instance, a data type int,
meaning integer is pre-defined in Java. You can declare as many
variables of type int as you need in your program:
Int day;
Int count;
Int divisor;
Int answer;
class serves as a plan, or template. It specifies what data, and what
functions will be included in objects of that class. Defining the
class doesn’t create any objects, just as the mere existence of a type
int doesn’t create any variables.
A class is thus a collection of similar objects. This fits our non-
technical understanding of the word class, Prince, sting etc., are
members of the class of rock musicians. There is no person called
rock musician but specific people with specific names are members
of this class if they possess certain characteristics.
4.9.1 Abstraction
An essential element of object-oriented programming is
abstraction. Humans manage complexity through abstraction. For
example, people do not think of a car as a set of tens of thousands
of individual parts. They think of it as a well-defined object with
its own unique behavior. This abstraction allows people to use a
car to drive to the grocery store without being overwhelmed by the
complexity of the parts that form the car. They can ignore the
22
LIVE DESKTOP
23
LIVE DESKTOP
4.9.2 Encapsulation
Encapsulation is the process of binding the code and the
data, thus providing security from the outside interface. The other
way of defining encapsulation is by providing the code and data
with a protective wrapper, thus preventing them from being
accessed by the code present outside the wrapper. Access to the
code and data inside the wrapper is tightly controlled through a
well defined interface. In Java the basis of encapsulation is the
class. A class defines the structure and behavior (data and code)
that will be shared by a set of objects. Each object of a given class
contains the structure and behavior defined by the class. For this
reason, objects are sometimes referred to as instances of a class.
Thus, a class is a logical construct; an object has physical reality.
Specifically, the data defined by the class are referred to as
member variables or instance variables. The code that operates on
that data is referred to as member methods or just methods.
Therefore, any other code that is not a member of the class cannot
access a private method or variable. Since the private members of
a class may only be accessed by other parts of your program
24
LIVE DESKTOP
through the class’ public methods, you can ensure that no improper
actions take place. Of course, this means that the public interface
should be carefully designed not to expose too much of the inner
workings of a class.
4.9.3 Inheritance
Inheritance is the process by which one object acquires the
properties of another object. This is important because it supports
the concept of hierarchical classification. As mentioned earlier,
most knowledge is made manageable by hierarchical (that is, top-
down) classifications. For example, a Golden Retriever is part of
the classification dog, which in turn is part of the mammal class,
which is under the larger class animal.
Without the use of hierarchies, each object would need to define
all of its characteristics explicitly. However, by use of inheritance,
an object need only define those qualities that make it unique
within its class. It can inherit its general attributes from its parent.
Thus, it is the inheritance mechanism that makes it possible for one
object to be a specific instance of a more general case. Most people
naturally view the world as made up of objects that are related to
each other in a hierarchical way, such as animals, mammals, and
dogs. If you wanted to describe animals in an abstract way, you
would say they have some attributes, such as size, intelligence, and
type of skeletal system. Animals also have certain behavioral
aspects; they hear, breathe, and sleep. This description of attributes
and behavior is the class definition for animals.
25
LIVE DESKTOP
4.9.4 Polymorphism
26
LIVE DESKTOP
27
LIVE DESKTOP
The user can pass three possible input parameters into these
methods:
28
LIVE DESKTOP
1. A single string that represents both the program to execute and any
arguments to that program
2. An array of strings that separate the program from its arguments
3. An array of environment variables
29
LIVE DESKTOP
BLOCK DIAGRAM
5. Block Diagram
31
LIVE DESKTOP
32
LIVE DESKTOP
WORKING
6. WORKING
33
LIVE DESKTOP
For all the clients to connect with server as shown in the fig below:-
Fig. Server Assigning the Port No.
After that a plain java frame will appear in which all the clients screen
which are connected are shown in minimized format.
Then user will click particular client’s window to see that particular
window.
After Clicking that Particular window Server can see Screen image of
client in Frame.
34
LIVE DESKTOP
After that Server Can Access the whole system of that Client As we are
Providing The Full Screen as Client has.
After that If server wants to see Screen of other Client, Server will
minimize the screen.
Then all client’s screen will appear in minimized format in the Frame
window.
35
LIVE DESKTOP
36
LIVE DESKTOP
This will then connect to the sever and will send the screen snapshots to
SERVER which will be shown in the FRAME as a Image.
Since the resolution on the both pc may differ Server must and Client
must take care that the Resolution is changing according to Server’s
Resolution.
37
LIVE DESKTOP
CODE
38
LIVE DESKTOP
import java.awt.BorderLayout;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import java.io.*;
import java.util.*;
/*
* this is the entry class of the server
*/
public class ServerInitiator
{
//Main server frame
private JFrame frame = new JFrame();
//JDesktopPane represents the main container that will contain all
//connected clients' screens
private JDesktopPane desktop = new JDesktopPane();
39
LIVE DESKTOP
if (done == 1 )
{
System.out.println("Server start started...");
String port = JOptionPane.showInputDialog("Please enter
listening port");
new ServerInitiator().initialize(Integer.parseInt(port));
}
If else
{
System.out.println("your session has been terminated");
}
}
main
40
LIVE DESKTOP
while(true)
{
//infine loop
Socket client = sc.accept();
//socket object accepting all connection
System.out.println("New client Connected to the server");
//Per each client create a ClientHandler
new ClientHandler(client,desktop);
//passing client socket object
}
}
catch (IOException ex)
{
ex.printStackTrace();
}
}
/*
Draws the main server GUI
*/
public void drawGUI()
{
frame.add(desktop,BorderLayout.CENTER);
//adding desktoppane object to frame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOS
E);
//close on clicking on cross
41
LIVE DESKTOP
42
LIVE DESKTOP
import java.awt.Rectangle;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.io.IOException;
import java.io.PrintWriter;
import java.net.Socket;
import javax.swing.JPanel;
43
LIVE DESKTOP
double xScale =
clientScreenDim.getWidth()/cPanel.getWidth();
//rectange width divided by panel width
System.out.println("xScale: " + xScale);
double yScale =
clientScreenDim.getHeight()/cPanel.getHeight();
//rectange height divided by panel height
System.out.println("yScale: " + yScale);
System.out.println("Mouse Moved");
44
LIVE DESKTOP
writer.println(EnumCommands.MOVE_MOUSE.getAbbrev()
);
writer.println((int)(e.getX() * xScale));
//get x codinate from server and multiply by xscale
writer.println((int)(e.getY() * yScale));
//get y codinate from server and multiply by yscale
writer.flush();
//flushed so next event can be passed with out interfering
}
45
LIVE DESKTOP
writer.println(EnumCommands.RELEASE_MOUSE.getAbbr
ev());
int button = e.getButton();
int xButton = 16;
//constants for specfing right or left button click
if (button == 3)
{
xButton = 4;
}
writer.println(xButton);
writer.flush();
}
46
LIVE DESKTOP
47
LIVE DESKTOP
48
LIVE DESKTOP
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
/**
*
* This class is responsible for connecting to the server
* and starting ScreenSpyer and ServerDelegate classes
*/
49
LIVE DESKTOP
try
{
System.out.println("Connecting to server ..........");
socket = new Socket(ip, port);
System.out.println("Connection Established.");
50
LIVE DESKTOP
GraphicsDevice gDev=gEnv.getDefaultScreenDevice();
51
LIVE DESKTOP
frame.setBounds(100,100,150,150);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(button);
52
LIVE DESKTOP
53
LIVE DESKTOP
try
{
//Read screenshots of the client then draw them
while(continueLoop)
{
//Recieve client screenshot and resize it to the current panel size
ImageIcon imageIcon = (ImageIcon)
cObjectInputStream.readObject();
//image Recived
System.out.println("New image recieved");
Image image = imageIcon.getImage();
//retrived image from imageicon object
image =
image.getScaledInstance(cPanel.getWidth(),cPanel.getHeight()
//getwight and height of panel
Image.SCALE_FAST);
//The SCALE_FAST gives priority to speed over smoothness of
image and store the new image int o image object
//Draw the recieved screenshot
Graphics graphics = cPanel.getGraphics();
graphics.drawImage(image, 0, 0,
cPanel.getWidth(),cPanel.getHeight(),cPanel);
//draw what ever is there in image object atart from 0,0 axis and go
till maxwight and hight of panel
}
}
54
LIVE DESKTOP
catch(ClassNotFoundException ex)
{
ex.printStackTrace();
}
}
}
55
LIVE DESKTOP
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import javax.swing.ImageIcon;
/*
This class is responisble for sending sreenshot every predefined
duration
*/
class ScreenSpyer extends Thread
{
56
LIVE DESKTOP
try
{
//Prepare ObjectOutputStream
oos = new ObjectOutputStream(socket.getOutputStream());
/*
* Send screen size to the server in order to calculate correct mouse
* location on the server's panel
*/
oos.writeObject(rectangle);
}
catch(IOException ex)
{
ex.printStackTrace();
}
57
LIVE DESKTOP
while(continueLoop)
{
//Capture screen
BufferedImage image = robot.createScreenCapture(rectangle);
/* I have to wrap BufferedImage with ImageIcon because
BufferedImage class
* does not implement Serializable interface
*/
ImageIcon imageIcon = new ImageIcon(image);
58
LIVE DESKTOP
catch(InterruptedException e)
{
e.printStackTrace();
}
}
}
}
59
LIVE DESKTOP
INFORMATIO
N
60
LIVE DESKTOP
In this article I will discuss how to use the java.net package to net enable
any application (CLI or GUI based) with TCP based sockets. The first
section will cover what sockets are and how they have been supported in
Java. In the second section, I will enumerate the steps you need to take to
use sockets within an application. In the last two sections I will develop a
real world application using sockets. That sets the course for this
discussion.
Of these only Internet Domain Sockets are supported across all platforms.
So to maintain the cross-platform characteristic intact, Java supports only
Internet Domain Sockets. The next question that arises is what are the
61
LIVE DESKTOP
1. TCP
2. UDP
3. Raw IP
TCP is one of the core protocols of the Internet protocol suite. The
protocol guarantees reliable and in-order (correct order of packets)
delivery of data from sender to receiver. To put it simply, it's reliable. The
second aspect of TCP is that it is connection oriented. That means TCP
requires that a connection be made between the sender and receiver
before data is sent. The socket associated with TCP is known as the
Stream Socket.
UDP, like TCP, is one of the core protocols of the IP suite. However,
unlike TCP, it neither guarantees in-order delivery of data nor does it
requires a connection to be established for sending the data. To put it
simply, UDP is an unreliable and connectionless protocol. Sockets
associated with UDP are known as Datagram Sockets.
62
LIVE DESKTOP
Next let's see how Java places the different types of sockets in its
libraries.
1. java.net package
2. ServerSocket
3. Socket
Among the above, Java abstracts out most of the low-level aspects of
socket programming. Here are the details.
The java.net package contains all the classes required to create network
enabled applications. ServerSocket and Socket are also part of this
package. Apart from these classes, it also contains classes to connect to
the web server, create secured sockets, and so forth.
The Socket class provides client-side sockets or simply sockets. They are
at the client side connecting to the server, sending the request to the
server and accepting the returned result. Just as ServerSocket exposes
only the compulsory parameters required to create a server-side socket,
similarly, Socket asks the user to provide only those parameters that are
most necessary.
That covers sockets and Java. In the next section, I will discuss the steps
involved in creating socket-based applications.
Any net enabled application has two important parts: the code that
executes at client-side and the code that executes at server-side. So using
the functionality of sockets can be partitioned into two major steps:
63
LIVE DESKTOP
8.3.1The Server
The server's main function is to wait for incoming requests, and to service
them when they come in. So the code to implement the server can be
further broken down to the following steps:
c. ServerSocket(int port, int backlog), which not only binds the created
socket to the port but also create a queue of length specified by the
number passed as the backlog parameter.
64
LIVE DESKTOP
a. Creating a Socket object. The socket at client side just needs to know
the host name (the name of the machine where server is running) and the
port where the server is listening. To create a Socket object, there are
seven constructors provided by the Socket class, of which the most
commonly used are:
65
LIVE DESKTOP
Contains all of the classes for creating user interfaces and for painting
graphics and images. A user interface object such as a button or a
scrollbar is called, in AWT terminology, a component. The Component
class is the root of all AWT components. See Component for a detailed
description of properties that all AWT components share.
Some components fire events when a user interacts with the components.
The AWTEvent class and its subclasses are used to represent the events
that AWT components can fire. See AWTEvent for a description of the
AWT event model.
Provides for system input and output through data streams, serialization
and the file system. Unless otherwise noted, passing a null argument to a
constructor or method in any class or interface in this package will cause
a NullPointerException to be thrown.
66
LIVE DESKTOP
This class is used to generate native system input events for the purposes
of test automation, self-running demos, and other applications where
control of the mouse and keyboard is needed. The primary purpose of
Robot is to facilitate automated testing of Java platform implementations.
Using the class to generate input events differs from posting events to the
AWT event queue or AWT components in that the events are generated in
the platform's native input queue. For example, Robot.mouseMove
will actually move the mouse cursor instead of just generating mouse
move events.
Applications that use Robot for purposes other than self-testing should
handle these error conditions gracefully.
67
LIVE DESKTOP
Robot
public Robot()
throws AWTException
Constructs a Robot object in the coordinate system of the primary
screen.
Throws:
AWTException - if the platform configuration does not allow low-
level input control
SecurityException - if createRobot permission is not granted
See Also:
SecurityManager.checkPermission(java.security.Perm
ission), AWTPermission
Robot
public Robot(GraphicsDevice screen)
throws AWTException
Creates a Robot for the given screen device. Coordinates passed to
Robot method calls like mouseMove and createScreenCapture will
be interpreted as being in the same coordinate system as the
specified screen. Note that depending on the platform
configuration, multiple screens may either:
68
LIVE DESKTOP
Parameters:
screen - A screen GraphicsDevice indicating the coordinate
system the Robot will operate in.
Throws:
AWTException - if the platform configuration does not allow low-
level input control
IllegalArgumentException - if screen is not a screen
GraphicsDevice.
SecurityException - if createRobot permission is not granted
8.7.1 mouseMove
public void mouseMove(int x,
int y)
Moves mouse pointer to given screen coordinates.
Parameters:
x - X position
y - Y position
8.7.2 mousePress
public void mousePress(int buttons)
Presses one or more mouse buttons.
Parameters:
buttons - Button mask (combination of
InputEvent.BUTTON1/2/3_MASK)
Throws:
IllegalArgumentException - if the button mask is not a valid
combination
8.7.3 mouseRelease
public void mouseRelease(int buttons)
Releases one or more mouse buttons.
Parameters:
69
LIVE DESKTOP
8.7.4 keyPress
public void keyPress(int keycode)
Presses a given key.
Key codes that have more than one physical key associated with
them (e.g. KeyEvent.VK_SHIFT could mean either the left or
right shift key) will map to the left key.
Parameters:
keyCode - Key to press (e.g. KeyEvent.VK_A)
Throws:
IllegalArgumentException - if keycode is not a valid key
8.7.5 keyRelease
public void keyRelease(int keycode)
Releases a given key.
Key codes that have more than one physical key associated with
them (e.g. KeyEvent.VK_SHIFT could mean either the left or
right shift key) will map to the left key.
70
LIVE DESKTOP
Parameters:
keyCode - Key to release (e.g. KeyEvent.VK_A)
Throws:
IllegalArgumentException - if keycode is not a valid key
71
LIVE DESKTOP
72
LIVE DESKTOP
73
LIVE DESKTOP
.
Where
Example Notes
Described
Desktop This section Launches the host system's default browser with the
Demo specified URI and default email client; launches an
application to open, edit, or print a file.
74
LIVE DESKTOP
SCREENS
TESTING
75
LIVE DESKTOP
9. TESTING:
76
LIVE DESKTOP
Graph Matrix:
For use with software to determine basic set of testing paths.
Loop testing:
Focus exclusively on the validity of loop constructs.
77
LIVE DESKTOP
1 Simple.
2 Nested.
3 Concatenated.
4 Unstructured.
• Interface errors.
• Performance errors.
78
LIVE DESKTOP
Black box testing is used for the testing of the program. Its tactics
consists of:
1 Equivalence Partitioning.
5 Stress Testing.
6 Sensitive Testing.
Test case 1:
Test case 2:
79
LIVE DESKTOP
Test case 3:
80
LIVE DESKTOP
APPLICATION
81
LIVE DESKTOP
10. APPLICATION
• Can be use in computer labs to monitor.
• To access a remote PC without going there.
• For security purpose in cyber café.
• Can also be used to control unattended computers and
servers.
82
LIVE DESKTOP
CONCLUSION
83
LIVE DESKTOP
11. CONCLUSION:
FUTURE SCOPE
85
LIVE DESKTOP
86
LIVE DESKTOP
REFERENCE
87
LIVE DESKTOP
13. BIBLIOGRAPHY:
A] Web Sites:-
1. http://java.sun.com/products/jfc/tsc/articles/accessibility/index.html
2. http://java.sun.com/products/jfc/tsc/articles/merlin/index.html
3. http://java.sun.com/products/jfc/tsc/articles/bidi/index.html
4. http://java.sun.com/products/jfc/tsc/articles/text/element_interface/
88
LIVE DESKTOP
B] Books:-
1. The JDK1.6 tutorial
- Greg Travis
89
LIVE DESKTOP
90