remote desktop

125
LIVE DESKTOP INTRODUCTION 1

Upload: chintan-parekh

Post on 25-Nov-2014

912 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Remote Desktop

LIVE DESKTOP

INTRODUCTION

1.1 INTRODUCTION TO PROJECT1

Page 2: Remote Desktop

LIVE DESKTOP

This project helps the user to remotely view the screen of a

system that is connected through a LAN. This also increases the

scope of the administrator, by accessing the files present on the

remote system and also to modify them. The modules present in

this project are explained in detail in the next chapter.

1.1.1 CURRENT SYSTEMS: In the present generation systems, there is a need for

the administrator has to go all around the network in order to

monitor the activities of any system, also to terminate that is

left non-terminated.

The administrator has to take all the trouble of going

to a particular system to access a file that is needed by him.

In order to get the system configuration details of any

particular system, the administrator has to take the trouble of

going to that system for obtaining the information.

The processes that are running in a particular system

can be viewed only in that system itself by using the present

generation software’s. Admin is not able to get the processes

the user is running.

In order to provide security for the files from

unauthorized users, the administrator has to assign the file

permissions. In the existing systems this is handled by

performing the required actions on that particular system

itself

1.1.2 PROPOSED SYSTEMS:

2

Page 3: Remote Desktop

LIVE DESKTOP

The disadvantages present in the existing systems can be overcome

using the proposal systems.

Using the Remote desktop software the administrator

can view the remote screen as well as control the operations

of the remote system from his system it self.

The administrator can get the configuration of the

remote system from the screen on the server system itself

using this software.

In order to ensure the security for the files in an

organization, the administrator can provide the file access

permissions directly on the remote machine.

3

Page 4: Remote Desktop

LIVE DESKTOP

SYSTEM ANALYSIS&

SOFTWARE REQUIREMENT SPECIFICATION

2.1 FEASIBILITY STUDY:

4

Page 5: Remote Desktop

LIVE DESKTOP

All projects are feasible, given unlimited resources and

infinite time. But the development of software is plagued by the

scarcity of resources and difficult delivery rates. It is prudent to

evaluate the feasibility of the project at the earliest possible time.

Three key considerations are involved in feasibility analysis.

2.1.1 Technical Feasibility:

Technical feasibility centers on the existing computer system

(Hardware, Software etc.,) and to what extent it can support the

proposed addition. If the budget is a serious constraint, then the

project is judged not feasible.

2.1.2 Economic Feasibility:

This procedure is to determine the benefits and savings that

are expected from a candidate system and compare them with

costs. It benefits outweigh costs, and then the decision is made to

design and implement the system. Otherwise, further justification

or alternations in proposed system will have to be made if it is to

have a chance of being approved. This is an ongoing effort that

improves in accuracy at each phase of the system lifecycle.

2.1.3 Operational Feasibility:

People are inherently resistant to change, and computers

have been known to facilitate change. It is understandable that the

introduction of a candidate system requires special effort to

educate, sell, and train the staff on new ways of conducting

business.

5

Page 6: Remote Desktop

LIVE DESKTOP

2.2 FEASIBILTY STUDY ABOUT THIS PROJECT

2.2.1 Technical Feasibility:

The Terminal Controller software is developed using the

java environment. The reason for using java, as the development

platform is that, java is an Object Oriented Language which

handles most of the networking concepts. Since java is a platform

independent language, the class files can be executed on any

operating system easily.

2.2.2 Economic Feasibility:

This is the most frequently used method for evaluating the

effectiveness of a system. It is also called as a cost analysis. The

Terminal Controller software, which is used to control all the

remote systems in a network, requires resources such as the

software and hardware components that support the Remote

desktop software effectively. Since all the clients are usually

connected to the server in any organization, it reduces the cost

factor. Hence there is no need of further physical connection to be

established between the server and the client.

2.2.3Operational Feasibility:

6

Page 7: Remote Desktop

LIVE DESKTOP

The Terminal Controller software is a user-friendly tool

developed in order to make the operations of the administrator

much better. It will be easy for the administrator to handle all the

systems in the network from the server itself which helps in

increasing the operational efficiency of the administrator.

2.3 SOFTWARE REQUIREMENT SPECIFICATION:

Software requirement specification (SRS) is the starting

point of the software developing activity. As system grew more

complex it became evident that the goal of the entire system cannot

be easily comprehended. Hence the needs for the requirement

phase arouse. The software project is initiated by the client needs.

The SRS is the means of translating the ideas of the minds of

clients (the input) into a formal document (the output of the

requirement phase).

2.3.1 The SRS phase consists of two basic activities:

2.3.1.1 Problem/Requirement Analysis :

The process is order and more nebulous of the two, deals with

understand the problem, the goal and constraints.

2.3.1.2 Requirement Specification:

7

Page 8: Remote Desktop

LIVE DESKTOP

Here, the focus is on specifying what has been found giving

analysis such as representation, specification languages and tools,

and checking the specifications are addressed during this activity.

The requirement phase terminates with the production of the

validate SRS document. Producing the SRS document is the basic

goal of this phase.

2.3.2 ROLE OF SRS :

The purpose of the software requirement specification is to

reduce the communication gap between the clients and the

developers. Software Requirement Specification is the medium

through which the client and user needs are accurately specified. It

forms the basis of software development. A good SRS should

satisfy all the parties involved in the system.

SOFTWARE SPECIFICATIONS:

8

Page 9: Remote Desktop

LIVE DESKTOP

OPERATING PLATFORM : WINDOWS XP, VISTA

FRONT END : JAVA, SOCKETS, SWINGS

HARDWARE SPECIFICATIONS:

PROCESSOR : PENTIUM-4

RAM : 256 MB.(MINIMUM)

HARD DISK : 20GB (MINIMUM)

VDU : SVGA COLOR

MONITOR

KEY BOARD : 104 STANDARDS

LAN : ENABLED

2.4 FUNCTIONAL REQUIREMENTS :

Functional requirements specify which output should be

produced from the given input. They describe the relationship

between the data and the methods to obtain the output. This

includes specifying the valid IP address and the desired operation

i.e. to be performed on the remote system.

9

Page 10: Remote Desktop

LIVE DESKTOP

SYSTEM DESIGN

10

Page 11: Remote Desktop

LIVE DESKTOP

3.1 SYSTEM DESIGN:

System design contains Logical Design & Physical

Designing, logical designing describes the structure &

characteristics or features, like output, input, files, database &

procedures. The physical design, which follows the logical design,

actual software & a working system. There will be constraints like

Hardware, Software, Cost, Time & Interfaces.

3.1.1 Design Objectives: System design is to deliver the requirements as specified in

the feasibility report. The main objectives of the design are

1.Practicality

2.Efficiency

3.Cost

4.Flexibility

5. Security

11

Page 12: Remote Desktop

LIVE DESKTOP

3.2 USE CASE VIEW OF THE TERMINAL

CONTROLLER SOFTWARE

The overall view of the Remote desktop software can be

understood using the following use case diagram. The following figure

gives the details of the modules present in the Remote desktop software.

Administrator

remote file searching

priviliges

remote system configuration

process management

login

remote system handling

Figure 1

12

Page 13: Remote Desktop

LIVE DESKTOP

.

IMPLEMENTATION

13

Page 14: Remote Desktop

LIVE DESKTOP

4.1 INTRODUCTION TO JAVA:

In the early days of the web, a server could dynamically construct a

page by creating a separate process to handle each client request. The

process would open connection to one or more databases in order to

obtain the necessary information. It communicated with the web server

via an interface known as the Common Gateway Interface (CGI) .CGI

allowed the separate process to read data from HTTP request and write

data to the HTTP response. A variety of different languages were used to

build CGI programs including C, C++ and Perl.

4.1.1 Features added by Java 1.5Version1.1 added some important elements to Java. Most of

the addition occurred in the Java library. However, a few new

language features were also included. Here is a list of the important

features added by 1.5:

Java Beans, which are software components that are written

in Java.

Serialization, which allows you to save and restore the state

of an object.

Remote Method Invocation, which allows a Java, objects to

invoke the methods of another Java object that located on a

different machine. This is an important facility for building

distributed applications.

Java Database Connectivity (JDBC), which allows programs

to access SQL, databases from many different vendors.

The Java Native Interface (JNI), which provides a new way

14

Page 15: Remote Desktop

LIVE DESKTOP

for your programs to interface with code libraries written in other

languages.

Reflection, which is a process of determining the fields,

constructors and methods of a java object at run time.

Various security features, such as digital signatures,

messages digests, and access control lists and key generation.

Built in support for 16-bit character streams that handle

Unicode characters.

Significant changes to event handling that improve the way

in which events generated by graphical user interface (GUI)

components are handled.

Inner classes, which allow one class to be defined within

another.

4.1.2 Features added by java 2.0Building upon 1.1, java 2.0 adds many important new

features. Here is a partial list.

Swing is a set of user interface components that is

implemented entirely in java You can use a look and feel that is

either specific to a particular operating system or uniform across

operating systems. You can also design your own look and feel.

Collections are group of objects. Java 2.0 provides several

types of collection, such as linked lists, dynamic arrays and hash

tables for use. Collections offer a new way to solve several

common-programming problems.

Digital certificates provide mechanism to establish the

identity of a user. You may think of them as electronic passports.

Java programs can parse and use certificates to enforce security

15

Page 16: Remote Desktop

LIVE DESKTOP

policies.

Text components can now receive Japanese, Chinese and

Korean characters from keyboard. Using a sequence of keystrokes

to represent one character does this.

The Common Object request Broker Architecture (CORBA)

defines an Object request Broker (ORB) and an Interface

Definition Language (IDL). Java 2.0 includes an ORB and an IDL

to java compiler. The latter generates code from an IDL

specification.

Performance improvements have been made in several areas.

A Just-In-Time (JIT) compiler is included in JDK.

Many browsers include a Java Virtual Machine that is used

to execute applets. Unfortunately, browsers JVM’s typically do not

include the latest java features. The java Plug-in solves this

problem. It directs a browser’s JVM .The JRE is a subset of the

JDK.It does not include the tools and classes that are used in a

development environment. Various tools such as Javac, Java and Javadoc have been enhanced. Debugger

and Profiler interfaces for the JVM arte available.

4.2.3 Java’s Magic: The Byte Code:The key that allows java to solve both the security and the

portability problems just described is that, the output of the java

compiler is not an executable code. Rather, it is Byte Code. Byte

Code is a highly optimized set of instructions designed to be

executed by virtual machine that the java Run-time system

emulates. However, the fact that a java program is interpreted helps

solve the major problems associated with downloading the

program over the Internet.

16

Page 17: Remote Desktop

LIVE DESKTOP

Here is why java was designed to be interpreted language.

Because java programs are interpreted rather than compiled .It is

easier to run them in wide variety of environments. Only the java

runtime system needs to be implemented for each platform.

Once the runtime package exists for a given system any java

program can run on it. If java were a compiled language then

different versions of the same program will have to exist for each

type of CPU connected to the Internet. Thus interpretation is the

easiest way to create truly portable programs. Although java was

designed to be interpreted, there is technically nothing about java

that prevents on the fly compilation of Byte Code into native code.

However, even if dynamic compilation were applied to Byte Code,

the portability and safety would still apply, because the run time

system would still be in change of the execution environment.

4.2 The Java Buzz Words:No discussion of the genesis of java is complete without a

look at the java buzzwords. Although the fundamentals that

necessitated the invention of java are portability and security, there

are other factors that played an important role on molding the final

form of the language. The java in the following list of buzzwords

summed up the key considerations.

Simple

Portable

Object-oriented

Robust

Multithreaded

Architectural-neutral

High performance

17

Page 18: Remote Desktop

LIVE DESKTOP

Distributed

Dynamic

4.3 OBJECT ORIENTED PROGRAMMING AND

JAVA

Object-oriented Programming was developed because of

limitations found in earlier approaches of programming. In order

appreciate what OOP does, we need to understand the limitations

present in the traditional programming.

4.3 PROCEDURAL LANGUAGES

The procedural languages include Pascal, C, Basic,

FORTRAN, and some other similar languages. Each statement in

these languages tells the computer to perform some operation. A

program in a procedural language is a list of instructions.

For very small programs no other organizing principle (often called

a paradigm) is needed. The programmer creates the list of

instructions, and the computer carries them out.

4.4 Division into Functions When programs become larger, a single list of instructions

becomes unwieldy. Few programmers can comprehend a program

18

Page 19: Remote Desktop

LIVE DESKTOP

of more than a few hundred statements unless it is broken down

into smaller units. For this reason the function was adopted as a

way to make programs more comprehensible to their human

creators. (The term function is used in C++ and C. In other

languages the same concept may be referred to as a subroutine, a

subprogram, or a procedure.) .

A program is divided into functions, and (ideally, at least)

each function has a clearly defined purpose and a clearly defined

interface to the other functions in the program.

The idea of breaking a program into functions can be further

extended by grouping a number of functions together into a larger

entity called a module, but the principle is similar: grouping a

number of components that carry out specific tasks.

Dividing a program into functions and modules is one of the

cornerstones of structured programming, the somewhat loosely

defined discipline that has influenced programming organization

for more than a decade.

4.5 Problems with Structured ProgrammingAs programs grow ever larger and more complex, even the

structured programming approach begins to show signs of strain.

You may have heard about the problems involved in program

19

Page 20: Remote Desktop

LIVE DESKTOP

development. The project is too complex, the schedule slips, more

programmers are added, complexity increases, costs skyrocket, the

schedule slips further, and disaster ensues. Analyzing the reasons

for these failures reveals that there are weaknesses in the

procedural paradigm itself. No matter how well the structured

programming approach is implemented, large programs become

excessively complex. The reasons for this failure of procedural

languages are mainly because of the role played by data.

4.6 Relationship to the Real WorldProcedural programs are often difficult to design. The

problem is that their chief components--functions and data

structures--don't model the real world very well. For example,

suppose you are writing a program to create the elements of a

graphics user interface: menus, windows, and so on. Quick now,

what functions will you need? What data structures? The answers

are not obvious, to say the least. It would be better if windows and

menus corresponded more closely to actual program elements.

4.7 New Data TypesThere are other problems with traditional languages. One is

the difficulty of creating new data types. Computer languages

typically have several built-in data types: integers, floating-point

numbers, characters, and so on. What if you want to invent your

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

20

Page 21: Remote Desktop

LIVE DESKTOP

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.

4.8 The object oriented approachThe fundamental idea behind object-oriented languages is to

combine into a single unit both data and the functions that operate

on that data. Such a unit is called an object.

An object’s functions, called member methods in Java,

typically provide the only way to access its data. If you want to

read the item and return the value to you, you call a member

function in the object. It will read the item and return the value to

you. You can’t access the data directly. The data is hidden, so it is

safe from accidental modification. Data and its functions are said

to be encapsulated into a single entity. Data encapsulation and data

hiding are key terms in the description of object-oriented

languages. A Java program typically consists of a number of

objects, which communicate with each other by calling one

another’s members functions. We should mention that what are

called member functions in C++ are called methods in Java. Also,

data items are referred to as instance variables. Calling an object’s

member function is referred to as sending a message to the object.

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,

21

Page 22: Remote Desktop

LIVE DESKTOP

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 AbstractionAn 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

details of how the engine, transmission, and braking systems work.

Instead they are free to utilize the object as a whole. A powerful

way to manage abstraction is through the use of hierarchical

classifications. This allows you to layer the semantics of complex

22

Page 23: Remote Desktop

LIVE DESKTOP

systems, breaking them into more manageable pieces. From the

outside, the car is a single object. Once inside, you see that the car

consists of several subsystems: steering, brakes, sound system, seat

belts, heating, cellular phone, and so on. In turn, each of these

subsystems is made up of more specialized units. The point is that

you manage the complexity of the car(or any other complex

system) through the use of hierarchical abstractions.

Hierarchical abstractions of complex systems can also be

applied to computer programs. The data from a traditional process-

oriented program can be transformed by abstraction into its

component objects. A sequence of process steps can become a

collection of messages between these objects. Thus, each of each

object describes its own unique behavior. You can treat these

objects as concrete entities that respond to messages telling them to

do something. This is the essence of object-oriented programming.

Object-oriented concepts form the heart of Java just as they form

the basis for human understanding. It is important that you

understand how these concepts translate into programs. As you

will see, object-oriented programming is a powerful and natural

paradigm for creating programs that survive the inevitable changes

accompanying the life cycle of any major software project,

including conception, growth, and aging. .

4.9.2 EncapsulationEncapsulation is the process of binding the code and the

data, thus providing security from the outside interface. The other

23

Page 24: Remote Desktop

LIVE DESKTOP

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.

Since the purpose of a class is to encapsulate complexity, there are

mechanisms for hiding the complexity of the implementation

inside the class. Each method or variable in a class may be marked

private or public. The public interface of a class represents

everything that external users of the class need to know, or may

know. The private methods and data can only be accessed by code

that is a member of the class.

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

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.

24

Page 25: Remote Desktop

LIVE DESKTOP

4.9.3 InheritanceInheritance 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.

If you wanted to describe a more specific class of animals, such as

mammals, they would have more specific attributes, such as type

of teeth, and mammary glands. This is known as a subclass of

animals, where animals are referred to as mammals’ super class.

25

Page 26: Remote Desktop

LIVE DESKTOP

Since mammals are simply more precisely specified animals, they

inherit all of the attributes from animals. A deeply inherited

subclass inherits all of the attributes from each of its ancestors in

the class hierarchy.

Inheritance interacts with encapsulation as well. If a given class

encapsulates some attributes, then any subclass will have the same

attributes plus any that it adds as part of its specialization. This is a

key concept, which lets object-oriented programs grow in

complexity linearly rather than geometrically. A new subclass

inherits all of the attributes of all of its ancestors. It does not have

unpredictable interactions with the majority of the rest of the code

in the system.

4.9.4 Polymorphism

Polymorphism (from the Greek, meaning “many forms”) is a

feature that allows one interface to be used for a general class of

actions. The specific action is determined by the exact nature of

the situation. Consider a stack (which is a last-in, first-out list).

You might have a program that requires three types of stack. One

stack is used for integer values, one for floating-point values, and

one for characters. The algorithm that implements each stack is the

same, even though the data being stored differs. In a non-object-

oriented language, you would be required to create three difference

sets of stack routines, with each set using different names.

However, because of polymorphism, in Java you can specify a

general set of stack routines that all share the same names.

26

Page 27: Remote Desktop

LIVE DESKTOP

More generally, the concept of polymorphism is often expressed by

the phrase “one interface, multiple methods.” This means that it is

possible to design a generic interface to a group of related

activities. This helps reduce complexity by allowing the same

interface to be used to specify a general class of action. It is the

compiler’s job to select the specific action (that is, method) as it

applies to each situation.

4.9.5 Polymorphism, Encapsulation, and Inheritance

Work TogetherWhen properly applied, polymorphism, encapsulation, and

inheritance combine to produce a programming environment that

supports the development of far more robust and scaleable

programs than does the process-oriented model. A well-designed

hierarchy of classes is the basis for reusing the code in which you

have invested time and effort developing and testing.

Encapsulation allows you to migrate your implementations over

time without breaking the code that depends on the public interface

of your classes. Polymorphism allows you to create clean,

sensible, readable, and resilient code.

4.10 INTRODUCTION TO RUNTIME CLASS:

Every Java application has a single instance of class

Runtime that allows the application to interface with the

27

Page 28: Remote Desktop

LIVE DESKTOP

environment in which the application is running. The current

runtime can be obtained from the getRuntime method.

Which retrieves the current Java Runtime Environment. That is the

only way to obtain a reference to the Runtime object. With that

reference, the user can The class java.lang.Runtime features a static

method called getRuntime(), run external programs by invoking the

Runtime class's exec() method. Developers often call this method

to launch a browser for displaying a help page in HTML.

There are four overloaded versions of the exec() command:

public Process exec(String command);

public Process exec(String [ ] cmdArray);

public Process exec(String command, String [ ] envp);

public Process exec(String [ ] cmdArray, String [ ]

envp);

For each of these methods, a command and possibly a set of

arguments is passed to an operating-system-specific function call.

This subsequently creates an operating-system-specific process (a

running program) with a reference to a Process class returned to the

Java VM. The Process class is an abstract class, because a specific

subclass of Process exists for each operating system.

The user can pass three possible input parameters into these

methods:

1. A single string that represents both the program to execute

and any arguments to that program

28

Page 29: Remote Desktop

LIVE DESKTOP

2. An array of strings that separate the program from its

arguments

3. An array of environment variables

29

Page 30: Remote Desktop

LIVE DESKTOP

BLOCK DIAGRAM

5. Block Diagram

Block Diagram of LIVE DESKTOP

30

Page 31: Remote Desktop

LIVE DESKTOP

Fig. Block Diagram of Socket connection

31

Page 32: Remote Desktop

LIVE DESKTOP

Fig. Block Diagram of Java Remote Control

32

Page 33: Remote Desktop

LIVE DESKTOP

WORKING

6. WORKING

6.1 SERVER SIDE: At server side the administrator will set the port no.

33

Page 34: Remote Desktop

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

Page 35: Remote Desktop

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

Page 36: Remote Desktop

LIVE DESKTOP

6.2 CLIENT SIDE

36

Page 37: Remote Desktop

LIVE DESKTOP

On client side client tries to connect with server by mentioning the

the IP address of the SERVER and PORT NO. mentioned by the

SERVER.

Fig are shown below:-

Fig. Asking IP address of server

Fig.Asking PORT no. Given by the Server

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

Page 38: Remote Desktop

LIVE DESKTOP

CODE

38

Page 39: Remote Desktop

LIVE DESKTOP

7.1 SERVER PART

7.1.1 SERVER INITIATOR/*

this class takes input for port no. to be listen and init the starts the

server

*/

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

39

Page 40: Remote Desktop

LIVE DESKTOP

private JDesktopPane desktop = new JDesktopPane();

public static void main(String args[] ) //throws

InterruptedException //for sleep

{

loginframe1 lf = new loginframe1(); //object of loginframe

Thread.sleep(20000);

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

public void initialize(int port)

{

try

{

ServerSocket sc = new ServerSocket(port);

//Show Server GUI

drawGUI();

40

Page 41: Remote Desktop

LIVE DESKTOP

//Listen to server port and accept clients connections

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_CLOSE);

//close on clicking on cross

41

Page 42: Remote Desktop

LIVE DESKTOP

//Show the frame in a maximized state

frame.setExtendedState(frame.getExtendedState()|

JFrame.MAXIMIZED_BOTH);

//maxmixe the rame such that it covers the tool bar too

frame.setVisible(true);

}

}

42

Page 43: Remote Desktop

LIVE DESKTOP

7.1.2 CLIENT COMMAND SENDER

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;

class ClientCommandsSender implements KeyListener,

MouseMotionListener,MouseListener

{

private Socket cSocket = null;

private JPanel cPanel = null;

private PrintWriter writer = null;

private Rectangle clientScreenDim = null;

ClientCommandsSender(Socket s, JPanel p, Rectangle r)

{

cSocket = s;

cPanel = p;

clientScreenDim = r;

43

Page 44: Remote Desktop

LIVE DESKTOP

//Associate event listners to the panel

cPanel.addKeyListener(this);

cPanel.addMouseListener(this);

cPanel.addMouseMotionListener(this);

try

{

//PrintWriter which will be used to send commands to

//the client

writer = new PrintWriter(cSocket.getOutputStream());

}

catch (IOException ex)

{

ex.printStackTrace();

}

}

public void mouseMoved(MouseEvent e)

{

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

Page 45: Remote Desktop

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

}

public void mousePressed(MouseEvent e)

{

System.out.println("Mouse Pressed");

writer.println(EnumCommands.PRESS_MOUSE.getAbbrev());

int button = e.getButton();

int xButton = 16;

if (button == 3)

{

xButton = 4;

}

writer.println(xButton);

writer.flush();

}

public void mouseReleased(MouseEvent e)

{

System.out.println("Mouse Released");

45

Page 46: Remote Desktop

LIVE DESKTOP

writer.println(EnumCommands.RELEASE_MOUSE.getAbbrev());

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();

}

//this is not implemented but writed due to user on repectiver

interface

public void mouseEntered(MouseEvent e)

{

}

//this is not implemented but writed due to user on repectiver

interface

public void mouseExited(MouseEvent e)

{

}

//this is not implemented but writed due to user on repectiver

interface

46

Page 47: Remote Desktop

LIVE DESKTOP

public void mouseClicked(MouseEvent e)

{

}

//this is not implemeted but writed due to user on repectiver

interface

public void mouseDragged(MouseEvent e)

{

}

//this is not implemented but writed due to user on repectiver

interface

public void keyTyped(KeyEvent e)

{

}

public void keyPressed(KeyEvent e)

{

System.out.println("Key Pressed");

writer.println(EnumCommands.PRESS_KEY.getAbbrev());

writer.println(e.getKeyCode());

writer.flush();

}

47

Page 48: Remote Desktop

LIVE DESKTOP

public void keyReleased(KeyEvent e)

{

System.out.println("Mouse Released");

writer.println(EnumCommands.RELEASE_KEY.getAbbrev());

writer.println(e.getKeyCode());

writer.flush();

}

}

48

Page 49: Remote Desktop

LIVE DESKTOP

7.2 CLIENT PART

7.2.1 CLIENT INITIATOR

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

Page 50: Remote Desktop

LIVE DESKTOP

public class ClientInitiator

{

Socket socket = null;

public static void main(String[] args)

{

String ip = JOptionPane.showInputDialog("Please enter server IP");

String port = JOptionPane.showInputDialog("Please enter server port");

new ClientInitiator().initialize(ip, Integer.parseInt(port));

}

public void initialize(String ip, int port )

{

Robot robot = null;

//Used to capture the screen

Rectangle rectangle = null;

//Used to represent screen dimensions

try

{

System.out.println("Connecting to server ..........");

socket = new Socket(ip, port);

System.out.println("Connection Established.");

//Get default screen device

GraphicsEnvironment

gEnv=GraphicsEnvironment.getLocalGraphicsEnvironment();

50

Page 51: Remote Desktop

LIVE DESKTOP

GraphicsDevice gDev=gEnv.getDefaultScreenDevice();

//Get screen dimensions

Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();

rectangle = new Rectangle(dim);

//Prepare Robot object

robot = new Robot(gDev);

//draw client gui

drawGUI();

//ScreenSpyer sends screenshots of the client screen

new ScreenSpyer(socket,robot,rectangle);

//ServerDelegate recieves server commands and execute

them

new ServerDelegate(socket,robot);

}

catch (UnknownHostException ex)

{

ex.printStackTrace();

}

catch (IOException ex)

{

ex.printStackTrace();

}

catch (AWTException ex)

{

ex.printStackTrace();

}

51

Page 52: Remote Desktop

LIVE DESKTOP

}

private void drawGUI()

{

JFrame frame = new JFrame("Remote Admin");

JButton button= new JButton("Terminate");

frame.setBounds(100,100,150,150);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.add(button);

button.addActionListener( new ActionListener()

{

public void actionPerformed(ActionEvent e)

{

System.exit(0);

}

}

);

frame.setVisible(true);

}

}

52

Page 53: Remote Desktop

LIVE DESKTOP

7.2.2 CLIENT COMMAND RECEIVER /*

this class is responsible for recieving client screenshot and

displaying

it in the server. Each connected client has a separate object of this

class

*/

import java.awt.Graphics;

import java.awt.Image;

import java.io.IOException;

import java.io.ObjectInputStream;

import javax.swing.ImageIcon;

import javax.swing.JPanel;

class ClientScreenReciever extends Thread

{

private ObjectInputStream cObjectInputStream = null;

private JPanel cPanel = null;

private boolean continueLoop = true;

public ClientScreenReciever(ObjectInputStream ois, JPanel p)

{

cObjectInputStream = ois;

cPanel = p;

//start the thread and thus call the run method

start();

}

53

Page 54: Remote Desktop

LIVE DESKTOP

public void run()

{

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

Page 55: Remote Desktop

LIVE DESKTOP

}

catch (IOException ex)

{

ex.printStackTrace();

}

catch(ClassNotFoundException ex)

{

ex.printStackTrace();

}

}

}

55

Page 56: Remote Desktop

LIVE DESKTOP

7.2.3 SCREEN SPYER

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

{

Socket socket = null;

Robot robot = null;

// Used to capture screen

Rectangle rectangle = null;

//Used to represent screen dimensions

boolean continueLoop = true;

//Used to exit the program

56

Page 57: Remote Desktop

LIVE DESKTOP

public ScreenSpyer(Socket socket, Robot robot,Rectangle rect)

{

this.socket = socket;

this.robot = robot;

rectangle = rect;

start();

}

public void run()

{

ObjectOutputStream oos = null;

//Used to write an object to the streem

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

Page 58: Remote Desktop

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);

//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 s0creenshot sent");

}

catch (IOException ex)

{

ex.printStackTrace();

}

//wait for 100ms to reduce network traffic

try

{

Thread.sleep(100);

58

Page 59: Remote Desktop

LIVE DESKTOP

}

catch(InterruptedException e)

{

e.printStackTrace();

}

}

}

}

59

Page 60: Remote Desktop

LIVE DESKTOP

INFORMATION

60

Page 61: Remote Desktop

LIVE DESKTOP

8.1 Socket Programming in Java

In a world which is wired, standalone applications are becoming obsolete.

The facilitators for the connectivity of applications, at a low level, are

sockets. Any language, whether high-level or low-level, must provide

APIs to handle sockets if its creators want it to be widely accepted.

Java is no exception. Java facilitates socket programming through its java.net package. And true to its philosophy, it abstracts out most of the low-level "nitty-gritty" associated with sockets and provides a clean object-oriented API to work with.

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.

Sockets: what are they?

If one looks up the definition, the most common one would be "A socket is one endpoint of a two-way communication link between two programs running on the network." To put it differently, it is through sockets that applications access the network and transmit data. The types of sockets are as varied as the purposes and platforms of applications. There are three types of sockets:

1. Unix Domain Sockets 2. Internet Domain Sockets 3. NS Domain Sockets

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 characteristics of an Internet Domain Socket and what protocols are supported by it? Here are the answers.

61

Page 62: Remote Desktop

LIVE DESKTOP

8.2 Internet Domain Sockets

By definition "An Internet socket (or commonly, a socket or network socket), is a communication end-point unique to a machine communicating on an Internet Protocol-based network, such as the Internet." All applications communicating through the Internet use a network socket. The feature that distinguishes a network sockets from other sockets is the protocols that it supports. The supported protocols are:

1. TCP 2. UDP 3. Raw IP

The difference between them is based on whether the protocol is connection oriented or not. Here are the details.

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.

Raw IP is a non-formatted protocol, unlike TCP and UDP. It works at network and transport layers. A socket associated with Raw IP is known as a Raw Socket. UDP and TCP sockets just receive the payload or the data, whereas Raw Sockets receive the header info of the packet along with the data. The downside of Raw Sockets is that they are tightly coupled with the implementation provided by the underlying host operating system .

Next let's see how Java places the different types of sockets in its libraries.

62

Page 63: Remote Desktop

LIVE DESKTOP

8.3 Sockets in Java

Like all other functionalities provided by Java, functionalities to work with sockets are also "packaged" as a package and its classes. The following are the package and its main classes that help in accessing sockets:

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 ServerSocket class provides server sockets or sockets at server side. Such sockets wait for requests over the network. Once such requests arrive, a server socket performs operations based on the request and may return a result. The ServerSocket class wraps most of the options required to create server-side sockets.

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:

1. The server or the server-side code 2. The client or the client-side code

63

Page 64: Remote Desktop

LIVE DESKTOP

The multi-threaded nature of former can always be guaranteed whereas the later may or may not be multi-threaded.

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:

1.  Establish a server that monitors a particular port. This is done by creating an instance of the ServerSocket class. There are four different ways to create an instance of ServerSocket. They are:

a. ServerSocket(),  which simply sets the implementation that means everything is taken as default values. 

b. ServerSocket(int port), which creates a server-side socket and binds the socket to the given port number.

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. 

d. ServerSocket(int port, int backlog, InetAddress bindAddr), which creates a server-side socket that is bound to the specified port number with the queue of length specified by the backlog and bound to the address specified by the bindAddr argument.

64

Page 65: Remote Desktop

LIVE DESKTOP

8.3.2 The Client

The main purpose of the client is to connect to the server and communicate with it using the connection. So coding a client requires the following steps: 

1. Connect to the server. Connecting to the server can be accomplished in two steps:

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:

Socket(), which creates a new Socket instance without connecting to host.

Socket(InetAddress address, int port), which creates a new Socket object and connects to the port specified at the given address.

Socket(java.lang.String host, int port), which works the same way as Socket(), except that instead of an address, the host name is used.

65

Page 66: Remote Desktop

LIVE DESKTOP

8.4 Package java.awt Description

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.

A container is a component that can contain components and other containers. A con tainer can also have a layout manager that controls the visual placement of components in the container. The AWT package contains several layout manager classes and an interface for building your own layout manager. See Container and LayoutManager for more information.

8.5 Package java.io Description

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

Page 67: Remote Desktop

LIVE DESKTOP

8.6 THE MAIN CLASS IN CLIENTINITIATOR IS :

8.6.1 ROBOT CLASS.

public class Robot extends Object

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.

Note that some platforms require special privileges or extensions to access low-level input control. If the current platform configuration does not allow input control, an AWTException will be thrown when trying to construct Robot objects. For example, X-Window systems will throw the exception if the XTEST 2.2 standard extension is not supported (or not enabled) by the X server.

Applications that use Robot for purposes other than self-testing should handle these error conditions gracefully.

67

Page 68: Remote Desktop

LIVE DESKTOP

8.6.2 Constructor Details

Robotpublic 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.Permission), AWTPermission

Robotpublic 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:

share the same coordinate system to form a combined virtual screen

use different coordinate systems to act as independent screens

This constructor is meant for the latter case.

If screen devices are reconfigured such that the coordinate system is affected, the behavior of existing Robot objects is undefined.

Parameters:

68

Page 69: Remote Desktop

LIVE DESKTOP

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 Method Detail

8.7.1 mouseMovepublic void mouseMove(int x, int y)

Moves mouse pointer to given screen coordinates. Parameters: x - X position y - Y position

8.7.2 mousePresspublic 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 mouseReleasepublic void mouseRelease(int buttons)

Releases one or more mouse buttons. Parameters:

69

Page 70: Remote Desktop

LIVE DESKTOP

buttons - Button mask (combination of InputEvent.BUTTON1/2/3_MASK) Throws: IllegalArgumentException - if the button mask is not a valid combination

8.7.4 keyPresspublic 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 keyReleasepublic 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

Page 71: Remote Desktop

LIVE DESKTOP

Parameters: keyCode - Key to release (e.g. KeyEvent.VK_A) Throws: IllegalArgumentException - if keycode is not a valid key

8.8 The Desktop Class

Java™ Standard Edition version 6 narrows the gap between performance and integration of native applications and Java applications. Along with the new system tray functionality, splash screen support, and enhanced printing for JTables , Java SE version 6 provides the Desktop API (java.awt.Desktop) API, which allows Java applications to interact with default applications associated with specific file types on the host platform.

71

Page 72: Remote Desktop

LIVE DESKTOP

New functionality is provided by the Desktop class. The API arises from the JDesktop Integration Components (JDIC) project. The goal of the JDIC project is to make "Java technology-based applications first-class citizens" of the desktop, enabling seamless integration. JDIC provides Java applications with access to functionalities and facilities provided by the native desktop. Regarding the new Desktop API, this means that a Java application can perform the following operations:

Launch the host system's default browser with a specific Uniform Resource Identifier (URI)

Launch the host system's default email client Launch applications to open, edit, or print files associated with

those applications

Use the isDesktopSupported() method to determine whether the Desktop API is available. On the Solaris Operating System and the Linux platform, this API is dependent on Gnome libraries. If those libraries are unavailable, this method will return false. After determining that the Desktop API is supported, that is, the isDesktopSupported() returns true, the application can retrieve a Desktop instance using the static method getDesktop() .

If an application runs in an environment without a keyboard, mouse, or monitor (a "headless" environment), the getDesktop() method throws a java.awt.HeadlessException.

Once retrieved, the Desktop instance allows an application to browse, mail, open, edit, or even print a file or URI, but only if the retrieved Desktop instance supports these activities. Each of these activities is called an action, and each is represented as a Desktop.Action enumeration instance:

BROWSE — Represents a browse action performed by the host's default browser.

MAIL — Represents a mail action performed by the host's default email client.

OPEN — Represents an open action performed by an application associated with opening a specific file type.

EDIT — Represents an edit action performed by an application associated with editing a specific file type

PRINT — Represents a print action performed by an application associated with printing a specific file type.

72

Page 73: Remote Desktop

LIVE DESKTOP

Different applications may be registered for these different actions even on the same file type. For example, the Firefox browser may be launched for the OPEN action, Emacs for the EDIT action, and yet a different application for the PRINT action. Your host desktop's associations are used to determine which application should be invoked. The ability to manipulate desktop file associations is not possible with the current version of the Desktop API in JDK 6, and those associations can be created or changed only with platform-dependent tools at this time.

8.9 The Desktop API The Desktop class allows Java applications to launch the nativedesktop applications that handle URIs or files.Method Purpose

isDesktopSupported()Tests whether this class is supported on the current platform. If it is supported, use getDesktop() to retrieve an instance.

getDesktop()

Returns the Desktop instance of the current browser context. On some platforms the Desktop API may not be supported. Use the isDesktopSupported() method to determine if the current desktop is supported.

isSupported(Desktop.Action)

Tests whether an action is supported on the current platform. Use the following constans of the Desktop.Action enum: BROWSE, EDIT, MAIL, OPEN, PRINT.

browse(URI) Launches the default browser to display a URI. If the default browser is not able to handle the specified URI, the application

73

Page 74: Remote Desktop

LIVE DESKTOP

registered for handling URIs of the specified type is invoked. The application is determined from the protocol and path of the URI, as defined by the URI class.

mail(URI)Launches the mail composing window of the user default mail client, filling the message fields specified by a mailto: URI.

open(File) Launches the associated application to open a file.

edit(File) Launches the associated editor application and opens a file for editing.

print(File)Prints a file with the native desktop printing facility, using the associated application's print command.

Examples That Use Desktop APIThe following table lists the example that uses the Desktop class integration

.

Example Where Described Notes

Desktop Demo

This section Launches the host system's default browser with the specified URI and default email client; launches an application to open, edit, or print a file.

74

Page 75: Remote Desktop

LIVE DESKTOP

SCREENS

TESTING75

Page 76: Remote Desktop

LIVE DESKTOP

9. TESTING:

9.1 TESTING PLAN:

Software testing is a critical element of software quality

assurance and represents the ultimate review of specification,

design and coding. Testing presents an interesting anomaly for the

software engineer.

9.1.1 Testing Objective includes:

Testing is a process of executing a program with the intent

of finding an error

A good test case is one that has a probability of finding an as yet

undiscovered error

A successful test is one that uncovers an undiscovered error.

76

Page 77: Remote Desktop

LIVE DESKTOP

9.1.2 Testing Principles:

All tests should be traceable to end user requirements

Tests should be planned long before testing begins

Testing should begin on a small scale and progress towards testing

in large

Exhaustive testing is not possible

To be most effective testing should be conducted by a independent

third party

9.2 TESTING STRATEGIES:

9.2.1Static Testing:

This form of testing includes disk checking, walk-through

and compilations.

9.2.2 Dynamic Testing:

1 WHITE BOX TESTING:

Basic Path Testing:

Ensures that every statement has been executed at least

once. Every decision has been executed on its true and false side.

Graph Matrix:

For use with software to determine basic set of testing paths.

Loop testing:

Focus exclusively on the validity of loop constructs.

77

Page 78: Remote Desktop

LIVE DESKTOP

Four kinds of loop

1 Simple.

2 Nested.

3 Concatenated.

4 Unstructured.

2 BLACK BOX TESTING:

Here the black box testing which is also called Functional

testing are used to check the function of each item and verify

whether it does everything it is supposed to do. The test cases are

derived based on the

definition of what the item is intended to, i.e. , on the equivalent

item specification.

It is vitally important to error check for the following:

Incorrect or Missing function.

Interface errors.

Errors in Data Structures.

Performance errors.

Black box testing, also called Behavioral testing, focuses on

the functional requirement of the software. Black box testing is not

78

Page 79: Remote Desktop

LIVE DESKTOP

an alternative to white box techniques rather it is complimentary

approach that is likely to uncover a different class of errors than

white box testing.

Unlikely White box testing, which is performed early in the

testing processes, Black box testing tends to be applied during later

stages of testing. Because Black box testing purposely disregards

control structure, attention is focused on information domain.

Black box testing is used for the testing of the program. Its tactics

consists of:

1 Equivalence Partitioning.

2 Boundary Value Analysis.

3 Cause Effect Testing.

4 Data Validation Testing.

5 Stress Testing.

6 Sensitive Testing.

9.3 TEST CASES

The test cases that are used in the project are:

Test case 1:

Whether the text box is accepting the data type it should accept and giving error messages for invalid data.

Test case 2:

Incase of invalid IP address, the system must generate an error message.

79

Page 80: Remote Desktop

LIVE DESKTOP

Test case 3:

Incase of the drive not specified the system should generate an error message.

80

Page 81: Remote Desktop

LIVE DESKTOP

APPLICATION

81

Page 82: Remote Desktop

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

Page 83: Remote Desktop

LIVE DESKTOP

CONCLUSION

83

Page 84: Remote Desktop

LIVE DESKTOP

11. CONCLUSION:

This project mainly concentrates on the work done by the

administrator. It helps the administrator to enhance his work

efficiency. The administrator can easily handle the remote systems

from the server. This also decreases the unnecessary time

consumption.

A main use of remote desktop software is remote

administration. However, remote desktop software can also be used

for "headless computers": instead of each computer having its own

monitor, keyboard, and mouse, or using a KVM switch, a monitor,

keyboard and mouse can be attached to one computer with remote

control software, and headless computers controlled by it. The

duplicate desktop mode is also useful for user support and

education. Remote control software combined with telephone

communication can be nearly as helpful for novice computer-users

as if the support staff were actually there.

Remote Desktop software helps the organization from

unnecessary power consumption. The administrator can search the

files present on the remote system and can even perform operations

such as uploading a file or downloading a file.

This software also helps the administrator to alter the file

permissions and also to control the process that are running on the

remote system. The administrator can even get details of the

84

Page 85: Remote Desktop

LIVE DESKTOP

remote.Hence this project can be implemented in LAN to control

the remote systems operations.

FUTURE SCOPE

85

Page 86: Remote Desktop

LIVE DESKTOP

12. ADDTIONAL FEATURES WHICH CAN

BE ADDED Copy paste.

Using other Devices on another pc.

Download files from Client.

Can track all the path server went.

86

Page 87: Remote Desktop

LIVE DESKTOP

REFERENCE

87

Page 88: Remote Desktop

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

Page 89: Remote Desktop

LIVE DESKTOP

B] Books:-1. The JDK1.6 tutorial

- Greg Travis

2. Complete Reference Java, 2nd Edition

- Herbert Schlitz

3. Core Java Foundation Class

- Kim Topley

4. Java Network Programming

- O’Reilly

5. DEITEL & DEITel JAVA HOW TO program

6. The Unified Modeling Language User Guide:

- Grady Booch, James Rumbaugh, Ivar Jacobson

7. Accessibility and the Swing Set & The Swing Connection,

Sun Microsystems, 1999.

- Mark Andrews

89

Page 90: Remote Desktop

LIVE DESKTOP

8. Coming Swing API Changes for Java 2 SDK, Standard

Edition, v. 1.4, The Swing Connection, Sun Microsystems, 2001

9. Component Orientation in Swing, , The Swing Connection,

Sun Microsystems, 1999.

- Ralph Karr

10. Core Java Foundation Classes (Core Series), Prentice Hall,

1998.

- Kim Topley

11. The Element Interface, The Swing Connection, Sun

Microsystems, 1999.

- Scott Violet

90