Project Description
VNC software will provide architecture in which there is one client to control Remote Machine (Server).
There will be one server application on the Remote Machine (Server).
The server application will receive the request from the client application and send periodically screen and updates to the client when requested.
Controlling the Remote Machine includes
Capturing Desktop
Mouse Handling
Keyboard Handling
JNC client
import java.awt.Color;
import java.awt.FlowLayout;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.*;
import javax.swing.JPanel;
import java.awt.event.*;
import java.net.Socket;
import java.net.UnknownHostException;
import java.io.ObjectInputStream;
import java.io.PrintWriter;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
public class JVNCclient extends JFrame implements MouseWheelListener
{
private JLabel screen;
private ObjectInputStream in;
private PrintWriter out;
private ScreenThread screenThread;
private ImageIcon i;
private Socket s;
private boolean stopped = false;
public JVNCclient()
{
int WIDTH = Toolkit.getDefaultToolkit().getScreenSize().width;
int HEIGHT = Toolkit.getDefaultToolkit().getScreenSize().height;
setTitle("Virtual Network Computing");
setBackground(Color.white);
screen = new JLabel();
getContentPane().setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
getContentPane().add(screen);
resize(WIDTH,HEIGHT-10);
addMouseListener(new MyMouseAdapter(this));
addMouseMotionListener(new MyMouseMotionAdapter(this));
addKeyListener(new MyKeyAdapter(this));
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent we)
{
stopped = true;
screenThread.stopRunning();
sendAndUpdate(JVNCconstant.CLOSE,0,0);
System.exit(0);
}
});
String serverName = JOptionPane.showInputDialog(this, "Enter Server name :", "Server", JOptionPane.INFORMATION_MESSAGE);
try
{
s = new Socket(serverName.trim(), 1166);
if (s==null)
{
System.out.println("No I/O");
System.exit(0);
}
else
{
in = new ObjectInputStream(s.getInputStream());
out = new PrintWriter(s.getOutputStream());
screenThread = new ScreenThread();
}
}
catch (Exception ex)
{
JOptionPane.showMessageDialog(null,"Server not found on PORT number 1166");
System.exit(0);
}
}
public void updateScreen(final ImageIcon i)
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
screen.repaint();
screen.setIcon(i);
}
});
}
private void sendAndUpdate(int type,int arg1, int arg2)
{
String s = "" + type + "|" + arg1 + "|" + arg2;
out.println(s);
out.flush();
}
class MyMouseAdapter extends MouseAdapter
{
JVNCclient jvnc;
public MyMouseAdapter(JVNCclient jvnc)
{
this.jvnc = jvnc;
}
public void mousePressed(MouseEvent e)
{
sendAndUpdate(JVNCconstant.MOUSE_PRESS, e.getX(),e.getY());
}
public void mouseReleased(MouseEvent e)
{
sendAndUpdate(JVNCconstant.MOUSE_RELEASE,0,0);
}
}
class MyMouseMotionAdapter extends MouseMotionAdapter
{
JVNCclient jvnc;
public MyMouseMotionAdapter(JVNCclient jvnc)
{
this.jvnc = jvnc;
}
public void mouseDragged(MouseEvent e)
{
sendAndUpdate(JVNCconstant.MOUSE_MOVE, e.getX(), e.getY());
}
public void mouseMoved(MouseEvent e)
{
sendAndUpdate(JVNCconstant.MOUSE_MOVE,e.getX(), e.getY());
}
}
public void mouseWheelMoved(MouseWheelEvent e)
{
sendAndUpdate(JVNCconstant.MOUSE_WHEEL,e.getScrollAmount(),0);
}
class MyKeyAdapter extends KeyAdapter
{
JVNCclient jvnc;
public MyKeyAdapter(JVNCclient jvnc)
{
this.jvnc = jvnc;
}
public void keyPressed(KeyEvent ke)
{
int key;
key = ke.getKeyCode();
if(key==ke.VK_ENTER)
sendAndUpdate(JVNCconstant.KEY_PRESS_EVENTS,ke.VK_ENTER,0);
else if(key==ke.VK_F1)
sendAndUpdate(JVNCconstant.KEY_PRESS_EVENTS,ke.VK_F1,0);
else if(key==ke.VK_ESCAPE)
sendAndUpdate(JVNCconstant.KEY_PRESS_EVENTS,ke.VK_ESCAPE,0);
}
}
public static void main(String argv[])
{
JVNCclient f = new JVNCclient();
f.setVisible(true);
f.show();
}
private class ScreenThread implements Runnable
{
Thread t;
private boolean keepRunning;
ScreenThread()
{
keepRunning = true;
t = new Thread(this,"Screen Thread");
t.start();
}
public void run()
{
while (keepRunning)
{
try
{
if(stopped ==false)
{
if((i = (ImageIcon)in.readObject())!=null)
{
updateScreen(i);
Thread.sleep(1000);
i=null;
}
}
else
{
keepRunning = false;
in.close();
}
}
catch(InterruptedException e)
{
System.out.println("Thread Interrupted");
}
catch(OutOfMemoryError e)
{
e.toString();
JOptionPane.showMessageDialog(null,"JVM can not able to allocate Memory");
System.exit(0);
}
catch (ClassNotFoundException ex)
{
ex.printStackTrace();
}
catch (Exception ex)
{
ex.printStackTrace();
JOptionPane.showMessageDialog(null,"Server is stoped");
System.exit(0);
}
}
}
public void stopRunning()
{
keepRunning = false;
}
}
}
JVNC-constant
public class JVNCconstant
{
public static final int CLOSE = 0;
public static final int MOUSE_MOVE = 1;
public static final int MOUSE_PRESS = 2;
public static final int MOUSE_RELEASE = 3;
public static final int MOUSE_WHEEL = 4;
public static final int KEY_PRESS = 6;
public static final int KEY_RELEASE = 7;
public static final int KEY_TYPED = 5000;
public static final int KEY_PRESS_EVENTS = 12345;
}
JNC-server
import java.awt.AWTException;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.ObjectOutputStream;
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.SocketException;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import java.awt.event.*;
public class JVNCserver
{
private final int WIDTH = Toolkit.getDefaultToolkit().getScreenSize().width;
private final int HEIGHT = Toolkit.getDefaultToolkit().getScreenSize().height;
private final Rectangle screenRect = new Rectangle(0, 0, WIDTH, HEIGHT);
public Socket socket;
public ServerSocket s;
private CaptureThread capturethread;
private CaptureEvents captureevents;
private Robot robot;
private ObjectOutputStream out;
private BufferedReader in;
private BufferedImage i;
Image image;
public static void main(String arg[])
{
JVNCserver s = new JVNCserver();
}
public JVNCserver()
{
try
{
s = new ServerSocket(1166);
socket = s.accept();
System.out.println("Server Started");
out = new ObjectOutputStream(socket.getOutputStream());
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
robot = new Robot();
capturethread = new CaptureThread();
captureevents = new CaptureEvents();
}
catch (IOException ex)
{
ex.printStackTrace();
}
catch(Exception e)
{
e.printStackTrace();
JOptionPane.showMessageDialog(null,"server is stop");
}
}
public void sendImage() throws IOException
{
i = robot.createScreenCapture(screenRect);
image = i.getScaledInstance(WIDTH, HEIGHT-60, Image.SCALE_SMOOTH);
out.writeObject(new ImageIcon(image));
i.flush();
image.flush();
out.flush();
}
private class CaptureThread implements Runnable
{
private volatile boolean keepRunning;
Thread thread;
CaptureThread()
{
thread = new Thread(this,"Capture Thread");
keepRunning = true;
thread.start();
}
public void run()
{
while (keepRunning)
{
try
{
sendImage();
Thread.currentThread().sleep(8000);
//Thread.currentThread().sleep(20000);
}
catch(InterruptedException e1)
{
System.out.println("Thread Stop");
}
catch (IOException ex)
{
ex.printStackTrace();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"server is stoped");
}
}
}
public void stopRunning()
{
keepRunning = false;
}
}
private class CaptureEvents implements Runnable
{
private volatile boolean keepRunning;
Thread thread;
private int HY = HEIGHT / 2;
int y;
CaptureEvents()
{
thread = new Thread(this,"Capture Events");
keepRunning = true;
thread.start();
}
public void run()
{
while (keepRunning)
{
try
{
if (in!=null)
{
String e = (String)in.readLine();
if (e!=null)
{
//System.out.println(e);
int eventType = Integer.parseInt(e.substring(0, e.indexOf("|")));
int arg1 = Integer.parseInt(e.substring(e.indexOf("|")+1, e.lastIndexOf("|")));
int arg2 = Integer.parseInt(e.substring(e.lastIndexOf("|")+1));
//System.out.println(arg1+"-"+arg2);
if(eventType==JVNCconstant.CLOSE)
{
keepRunning = false;
in.close();
out.close();
return;
}
if(arg2 < y =" arg2"> HY)
y = arg2 + 21;
if (eventType == JVNCconstant.MOUSE_MOVE)
robot.mouseMove(arg1,y);
else if (eventType == JVNCconstant.MOUSE_PRESS)
{
robot.mousePress(InputEvent.BUTTON1_MASK);
}
else if (eventType==JVNCconstant.MOUSE_RELEASE)
robot.mouseRelease(InputEvent.BUTTON1_MASK);
else if(eventType== JVNCconstant.MOUSE_WHEEL)
robot.mouseWheel(arg1);
else if(eventType == JVNCconstant.KEY_PRESS_EVENTS)
{
switch(arg1)
{
case KeyEvent.VK_ENTER:
robot.keyPress(KeyEvent.VK_ENTER);
break;
case KeyEvent.VK_F1:
robot.keyPress(KeyEvent.VK_F1);
break;
case KeyEvent.VK_ESCAPE:
robot.keyPress(KeyEvent.VK_ESCAPE);
break;
}
}
}
}
else
System.out.println("In empty");
//Thread.currentThread().sleep(50);
}
/*catch(InterruptedException e)
{
System.out.println("Thread Stop");
}*/
catch(SocketException ex)
{
ex.printStackTrace();
JOptionPane.showMessageDialog(null,"Client is stopped");
break;
}
catch (IOException ex)
{
ex.printStackTrace();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"Server is stop");
}
}
}
public void stopRunning()
{
keepRunning = false;
}
}
}
Robot-check
import java.awt.Robot;
import java.awt.event.*;
import java.awt.*;
class RobotCheck
{
public static void main(String argv[])
{
int WIDTH = Toolkit.getDefaultToolkit().getScreenSize().width;
int HEIGHT = Toolkit.getDefaultToolkit().getScreenSize().height;
try
{
System.out.println(WIDTH +" " + HEIGHT);
Robot robot = new Robot();
robot.mousePress(InputEvent.BUTTON1_MASK);
System.out.println(KeyEvent.VK_ENTER);
System.out.println(KeyEvent.VK_F1);
//robot.keyPress(KeyEvent.VK_ENTER);
//robot.mouseMove(12,555);
}
catch(Exception e)
{
}
}
}
Project-Report
PROJECT REPORT ON
Virtual Network Computing (VNC)
In partial fulfillment of the requirement of
M.Sc (Computer Science) Part I [Semester I]
University of Pune
Developed By: –
Saraswati Porje
Ankita Singh
Sagar Saibi
DEPERTMENT OF COMPUTER SCIENCE
FERGUSSION COLLEGE, PUNE
2004-2005
CERTIFICATE
This is to certify that the students with names
Saraswati Porje
Ankita Singh
Sagar Saibi
of Fergusson College have successfully completed the project titled
VNC (Virtual Network Computing)
using “Java” language, towards the partial completion of
M.Sc (Computer Science) Part I (Semester I) for the University of Pune
during the academic year 2004-2005
ACCEPTANCE
This menu script has been read and accepted in satisfaction of the project requirement of the M.Sc.(Computer Science) Part I [Semester I] course of University of Pune during the period December 2004 to April 2005.
Examiner Signature
1.
2.
3.
4.
Date:
Place: Pune
INDEX
ACKNOWLEDGEMENT
We take this opportunity to express our sincere thanks to all the people who have guided us in our project entitled “Virtual network Computing (VNC)”.
We are very grateful to our project guides.
We are also thankful to our faculty,
1.
2.
3.
who have helped us with our project.
We express our gratitude to Mr. for the excellent lab facilities provided.
Saraswati Porje.
Ankita Singh.
Sagar Saibi.
INTORDUCTION
There are times, as a window network, you would like to control certain aspects of machine seating remotely, without having to install and trigger an application on the remote machine that ill communicate with the clients machine.
Out software provides architecture in which there is one client to control the remote machine. There is one Sever application (Remote machine).
This Server application will receive all requests from the client application and send periodically screen and updates to client when requested.
When Client application connects to remote machine, it will receive the connection request and sends signals to Remote machine.
Controlling the remote machine includes
Capturing Desktop.
Mouse Handling.
Keyboard Handling.
Project Description
The project contains two modules. The Client side and Sever side. The Client side fro where user can operate sever/remote machine. The server is considered as remote machine.
The working of a project Virtual Network Computing (VNC) is described as follows:
The sever start execution and waits for connection with some client. When the client start it requires the IP address of Server/ Remote machine. After getting IP address the connection between and remote machine is established.
First the server captures the desktop and send to client with some processing.
The client receives image and display it because of that the user can see remote machine desktop.
Now when user does some operation events are created which then transferred to the server side. The server receive event and fires it on its desktop or machine so whatever user does at the client side is reflected at the sever side as appropriated action performed on the sever side. The server send back the new desktop with to some changes to client side.
The project uses mainly Robot class from Java.awt package. This class is useful for capturing the desktop and also fires the event that are came from client side because of that proper action is performed.
The project also uses WindowListener, MouseListener, MouseMotionListener, KeyListner to get which event occurred. These events are then send to the sever side.
At the sever side the screen is captured using the Robot class method CreateScreenCapture(Rect rect).
This process continues till server and client are alive when server stops the message is given to user on client machine and process ends.
HARDWARE AND SOFTWAE REQUIREMENTS
Hardware requirements:
Intel Processor.
Hard Disk Drive
16 MB RAM.
Software Requirements:
Operating System(Windows 9x).
JVM (JDK 1.4.1).
FEASIBILTY STUDY
From the inception of ideas for a software system, until it is implemented and delivered to customer and even after that the system undergoes gradual developments and evaluations.
The software is said to have life cycle composed of several phases.
At the feasibility stage, it is desirable that two or three different configuration will be pursed that satisfy the key technical requirement but which represent different level of ambition and cost.
Feasibility is the determination of whether or not a project is worth doing. A feasibility study is carried out select a best system that mate performance requirements.
The data collected during primary investigation examines system feasibilities that is likelihood that the system will be beneficial to the organization. Four tests for feasibility study are as follows :-
Technical Feasibility: This is concerned with specifying equipment and software that ill successfully satisfy the use considerably, but might include
v The feasibility to produce output in a given time because system is fast enough to handle multiple users.
v Response time under certain circumstances and ability to process a certain volume of transaction of a particular speed.
v Feasibility to communicate data to distant location.
Economical Feasibility: Economic analysis is the most frequently used technique used for evaluating the effectiveness of a proposed system. More commonly known as cost/benefit analysis the procedure is to determine the benefits and savings that are expected from a proposed system and compared them with cost. Though the cost of installing the system may appear high, it is one time investment. The resulting benefits is that automation results in turn around time. The resulting cost/benefit ratio is favorable.
Operational Feasibility: It is mainly related to human organizational as social aspects. The points to be considered are :- The system interface is standard, user friendly and provides extensive help. Hence no training is not required.
Social Feasibility: Social feasibility is determination of whether a proposed project will be acceptable to people or not, So this project is totally Social and Feasible.
LIMITATIONS AND FUTURE ENHANCEMENT
In this project the speed of sending screen image is low.
We will improve the speed of sending screen images in future.
The images will be compressed and sent of the destination machine,
this will reduce the network traffic and also as less data is to be passed
the transfer will be fast.
The images can be sent by encoding over the network so that even if the data is captured by some unwanted user their will be no problem for the system as the data is encoded.
The project can be enhanced to run the applications on the client/Server machine.
Currently the project is restricted to only one client machine. The project can be enhanced to contain screens of more than one client/Server.
This project can be enhanced to send a acknowledgement to the server machine to let the server know the whether the image was successfully received by the client.
BIBLOGRAPHY
Complete reference (5th Edition)
Herbert schildt.
How to write program using swing.
Detiel and Daita.l
Existing System :-
Proposed System :-
The proposed system is supposed show the desktop of the remote machine on the machine on which it is running.
This system is supposed to have two machines, one as server and the other as client.
The Server will start and wait for a client to establish a connection.
Client requires server machine’s IP address to connect.
When a client connects to the server a connection is establish for that particular client.
Then server sends image of the desktop of the server machine.
These images are sent after every specific time interval and update the client about the server’s desktop status.
Best Projects
Bug Trackingsystem,Books online shopping,college management system,HR management system,Internet banking,Online chat room ,Online exam,Telephone billing system,Banking application,ATM database,airways reservation system,virtual network computing ,calculator,SMTP(simple mail transfer protocol)
Archives
-
▼
2008
(101)
-
▼
June
(32)
- EAR Utility to Compare two EAR files
- J2EE recover(Email Recoverd password)
- Servlet Application
- A CLASS SHOWS HOW
- Back&Fore ground color changer
- Magnifier (VERY NICE)JAR
- Die Roller
- DCSoft DOS Casino
- Card Base Classes
- A Civilisation Game
- Javascript Command Interpreter
- Parellel Port Viewer
- Swing Code to Maintain CD Database
- A Pong Game
- A Basic Game
- Bomber Man
- Logo using Runnable Interface
- Led Digital Clock
- Server Insertion to DB
- File to Array Convertor (JAR file)
- Java Servlet & JDBC Code for Web Development
- Animated Movable Ball
- Beat it Game
- Guessing Game
- Applet game Template.
- SMTP
- Pizza Hut
- Texteditor
- Virtual Network Computing
- GUI For RDBMS
- Calculator
- Smart Mail(Big project)
-
▼
June
(32)
7 comments:
Hai how can i down load the project..
Hey buddy VNC projects runs cool but why is there an issue with the Keyboard?
I tested it,mouse and screen capturing is fine but keyboard(Client)doeasn't working????
@vasu : die !
I got error this error...
JVNCserver.java:173: unexpected type
required: variable
found : value
if(arg2 < y =" arg2"> HY)
^
JVNCserver.java:173: operator > cannot be applied to java.lang.String,int
if(arg2 < y =" arg2"> HY)
^
2 errors
Can u say y it is like dis.....
Change the code to this will work Fine
if(arg2 < y && arg2> HY)
Solved By Chandra And Dibya
Hello can you help , actually when i want to this project on two different systems, it connected the client and server by IP adders , but it stopped the server and client and give pop window with server stopped and Client stipped.
Please send reply on My mail: gnss1234@gmail.com or niranjan_verma51@yahoo.com
Thanks in advanced
Post a Comment