Recent Posts

Connect On Facebook

Saturday, 23 April 2011

Report to Server Using RMI

This RMI Program to report The content in remote Server.This Code will use to for report your Server.Remote method invocation is best one in Java.In below example code this technique will use.please usea as following steps to run this program.




Steps:

1) create serializale Interface DataBaseAccessMethods
2) create DataBaseAction
3) create ReportServer(Rmi Server)
4) create ReportUser(Client)
5) run commandpromt  rmic DataBaseAction
6) run rmiregistry with port
7) run RmiServer(ReportServer)
8) run Rmiclient(ReportUser)

DataBaseAccessMethods.java

import java.rmi.*;
import java.awt.*;
public interface DataBaseAccessMethods extends Remote
{
    public String login(String username,String Password)throws RemoteException,Exception;
      public void reportMsgs(String user,String msg,String place,String cdate)throws RemoteException,Exception;
      public void connection() throws RemoteException,Exception;
      public void close() throws RemoteException,Exception;
}


DataBaseAccessMethods.java

In this program Overwrite the DataBaseAccessMethods class...

import java.io.*;
import java.rmi.*;
import java.awt.*;
import java.rmi.server.UnicastRemoteObject;
import java.sql.*;
public class DataBaseAction extends UnicastRemoteObject implements DataBaseAccessMethods
{
    String url = "jdbc:odbc:report";
    String userID = "";
    String password = "";
    Statement DataRequest;
    Connection Db;
    ResultSet Results;
    PreparedStatement DataRequest1;
   
    String FirstName;
    String LastName;
    String printrow;
           
    public void connection() throws RemoteException,Exception
    {
        //try
        {
            Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver");
            Db = DriverManager.getConnection(url,userID,password);
        }
        //catch(Exception e)
        {
          //  System.out.println("Connection Error:"+e);
        }
    }
   
   
   
   
   
    public DataBaseAction()throws RemoteException
    {
        //System.out.println("Rmi Server is ready");
        super();
    }
  
   
    public String login(String username,String password)throws RemoteException,Exception
    {
        String name="";
        //try
        {
            connection();
            String query = "SELECT * FROM users where Username='"+username+"' and Password='"+password+"'";
            DataRequest = Db.createStatement();
            Results = DataRequest.executeQuery (query);
           
           
           
            boolean Records = Results.next();
            if (!Records )
            {
                name="";
            }
            else
            {
                name = Results.getString ("Name") ;
               
            }
            close();
        }
        //catch(Exception e)
        {
//            System.out.println("Select Action Error:"+e);
        }
        return name;
    }
    public void reportMsgs(String user,String msg,String place,String cdate)throws RemoteException,Exception
    {
  //      try
        {
            connection();
            String query = "insert into msgs (users,place,message,Cdate) values ('"+user+"','"+msg+"','"+place+"',#"+cdate+"#)";
            System.out.println(query);
            DataRequest = Db.createStatement();
            DataRequest.executeUpdate(query);
            close();
        }
    //    catch(Exception e)
        {
      //      System.out.println("Insert Action Error:"+e);
        }
    }
    public void close() throws RemoteException,Exception
    {
        //try
        {
            DataRequest.close();
            DataRequest.close();
            Db.close();
        }
        //catch(Exception e)
        {
          //  System.out.println("Close Error:"+e);
        }
    }
      
}       

Design a RMI server...

DataBaseAccessMethods.java


import java.io.*;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
public class ReportServer
{
    public static void main(String arg[])throws Exception
    {
        //try
        {
                    DataBaseAction s1=new DataBaseAction();
                    Naming.rebind("Reporting",s1);
                    System.out.println("Report Server is ready");
        }
        //catch(RemoteException e)
        {
        //    System.out.println(e);
        }
    }
}

Design a RMI Client....

ReportUserWindow.java

import java.net.*;
import java.io.DataInputStream;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
import javax.swing.*;
import java.awt.event.*;
import java.util.Date;

import java.awt.*;
public class ReportUserWindow
{
    public static void main(String arg[])throws Exception
    {
        WindowD win=new WindowD();
    }
       
}
class WindowD extends JFrame implements ActionListener
{
    Date d;
    JPanel left, right, top, bottom, center;// Panels
    JLabel banner;
    //JFrame win;
    JLabel uname,pass;
    JTextField tuname;
    JPasswordField tpass;
    JButton login,send;
   
   
    JLabel username,date,msgs,place;
    JTextField tusername,tdate,tplace;
    JTextArea tmsgs;
    JScrollPane smsgs;
   
    WindowD()
    {
        d=new Date();
        setLayout(new BorderLayout());
        left = new JPanel();
        right = new JPanel();
        top = new JPanel();
        bottom = new JPanel();
        center = new JPanel();
        add(left, BorderLayout.WEST);
        add(right, BorderLayout.EAST);
        add(top, BorderLayout.NORTH);
        add(bottom, BorderLayout.SOUTH);
        add(center, BorderLayout.CENTER);
        uname=new JLabel("Username:");
        pass=new JLabel("Password:");
        tuname=new JTextField();
        tpass=new JPasswordField();
       
        login=new JButton("Login");
        center.setLayout(null);
        uname.setBounds(20,20,80,20);
        center.add(uname);
        tuname.setBounds(120,20,80,20);
        center.add(tuname);
        pass.setBounds(20,50,80,20);
        center.add(pass);       
       
        tpass.setBounds(120,50,80,20);
        center.add(tpass);
       
        login.setBounds(120,80,80,20);
        center.add(login);
       
        center.setSize(100,100);
       
        banner = new JLabel("------------Reporter---------");
        top.add(banner);
        setSize(300, 400);
    setVisible(true);
        login.addActionListener(this);
    }
    public void actionPerformed(ActionEvent e)
    {
        JButton mi = (JButton)e.getSource();
    String s = mi.getText();
       
    if (s.equals("Login"))
    {
            try
            {
               String stuname=tuname.getText();
               String stpass=tpass.getText();
               Object obj=Naming.lookup("Reporting");
               DataBaseAccessMethods data=(DataBaseAccessMethods)obj;
               String rname=data.login(stuname,stpass);
               if(!rname.equals(""))
               {
                    System.out.println("gggg"+rname);
                    center.removeAll();
                    repaint();
                    username=new JLabel("Username:");
                    date=new JLabel("Date:");
                    msgs=new JLabel("Messages:");
                    place=new JLabel("Place:");;
                   
                    tusername=new JTextField();
                    tusername.setText(rname);
                   
                   
                    int date1=d.getDate();
                    int month=d.getMonth();
                    int year1=d.getYear();
                    String sss=d.toGMTString();
                    tdate=new JTextField();
                    tdate.setText(""+date1+"/"+month+"/"+year1);
                    System.out.println(sss);
                    tmsgs=new JTextArea();
                    smsgs=new JScrollPane(tmsgs);
                    tmsgs.setText("");
                    tplace=new JTextField();
                    send=new JButton("Send");
                    send.addActionListener(this);
                    username.setBounds(20,20,80,20);
                    tusername.setBounds(120,20,80,20);
                    date.setBounds(20,50,80,20);
                    tdate.setBounds(120,50,80,20);
                    msgs.setBounds(20,80,80,20);
                    smsgs.setBounds(120,80,80,60);
                    place.setBounds(20,150,80,20);
                    tplace.setBounds(120,150,80,20);
                    send.setBounds(120,180,80,20);
                    center.add(username);
                    center.add(tusername);
                    center.add(date);
                    center.add(tdate);
                    center.add(msgs);
                    center.add(smsgs);
                    center.add(place);
                    center.add(tplace);
                    center.add(send);
               }
           }
       catch(Exception ee)
       {
        System.out.println(ee);
       }
        }
        if (s.equals("Send"))
    {
            try
            {
               String stuname=tusername.getText();
               String cdate=tdate.getText();
               String msg=tmsgs.getText();
               String place=tplace.getText();
               Object obj=Naming.lookup("Reporting");
               DataBaseAccessMethods data=(DataBaseAccessMethods)obj;
               data.reportMsgs(stuname,msg,place,cdate);
               tmsgs.setText("");
               tplace.setText("");
              
           }
       catch(Exception ee)
       {
        System.out.println(ee);
       }
        }
    }
}

JavaScript Blendering Effect


Blend Filter:

Here We write the Html Examples for Blundering effect. This Blundering effects most use for Web designing .Blundering effects are mostly use in web pages opening and closing times.here we give the sample of code and example.you copy this code and run it .you get the result of Blundering.you also run our  example.Thank you.

Below code used for Blundering Effect..









Java Remote Desktop Monitoring

Following Code used to Remote Desktop Monitoring....
This following code to capture the client Screen and send it to the server.Server to Record the Screen on hard disk .This program to implement the Server socket concept.This code is very good one.here not implement Multi-threading.you have used to multi threading and captures all you client screen

ImageCapture.java

1.This code client side code

2. This code Capture the current window screen and sends to particular server system .


import java.io.*;
import java.awt.*;
import java.awt.Image.*;


import java.net.*;
import java.io.File;
import java.util.*;
import java.lang.*;


import java.awt.Image;
import java.io.Serializable;
import java.applet.Applet;
import javax.swing.*;
import java.awt.*;
import java.io.*;
import java.awt.datatransfer.*;
import java.awt.event.*;
import javax.swing.filechooser.FileFilter;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.undo.*;
import javax.swing.colorchooser.ColorChooserComponentFactory;
import sun.beans.editors.StringEditor;
import javax.swing.plaf.MenuBarUI;
import javax.swing.text.*;
   
import javax.imageio.ImageIO;
import java.net.*;
import com.sun.image.codec.jpeg.*;
import java.awt.image.BufferedImage;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import javax.imageio.ImageIO;
import java.awt.geom.*;


public class ImageCapture implements Runnable
{
        boolean act=true;
        public Robot robo;
        byte [] dataone;
        int count=0;
        public BufferedImage myImage;
        //public  InetAddress multicastAddress;
        public  Socket socket;
        Thread main;
        public static void main(String args[])
        {
                try
                {
                       ImageCapture img=new ImageCapture();
                 }
                catch(Exception e)
                {
                        System.out.println("Errr inImgcanvas "+e);
                }
        }
        public ImageCapture()
        {
                try
                {
                        robo=new Robot();
                            if(act==true)
                            {
                                main=new Thread(this);
                                main.start();
                                System.out.println("Started");
                            }
                            else
                            {
                                main.stop();
                                System.out.println("Stoped");   
                            }
                       
                }
                catch(Exception e)
                {
                        System.out.println("Errr inImgcanvas cons "+e);
                }
        }


       public void run()
        {
                try
                {
                   
                      for (;;)
                    {
                            //if(act==true)
                            {
                                System.out.println("Started");
                                myImage=robo.createScreenCapture(new Rectangle(0,0,800,800));                              


                                int x1=155;int y1=150;int x2=205;int y2=185;
                                int red = 255;
                                int green = 0;
                                int blue = 0;
                                int transparency =100;
                               
                                Graphics graphics = myImage.getGraphics();
                                Color color = new Color(red, green,blue,255 * transparency/100);
                                graphics.setColor(color);
                                graphics.drawString("Screen Capture " +new java.util.Date(),50, myImage.getHeight() - 10);
                                int thumbWidth=500,thumbHeight=500;
                                double thumbRatio =(double)thumbWidth /(double)thumbHeight;
                                int imageWidth =myImage.getWidth(null);
                                int imageHeight=myImage.getHeight(null);
                                double imageRatio =(double)imageWidth / (double)imageHeight;
                                if (thumbRatio <imageRatio) {
                                        thumbHeight =(int)(thumbWidth /imageRatio);
                                } else {
                                        thumbWidth =(int)(thumbHeight *imageRatio);
                                }
                                BufferedImage thumbImage = new BufferedImage(thumbWidth,thumbHeight,BufferedImage.TYPE_INT_RGB);
                                Graphics2D graphics2D=thumbImage.createGraphics();
                                graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,RenderingHints.VALUE_INTERPOLATION_BILINEAR);
                                graphics2D.drawImage(myImage, 0, 0,thumbWidth,thumbHeight, null);
                                BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream("screencapture.jpg"));
                                JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
                                JPEGEncodeParam param= encoder.getDefaultJPEGEncodeParam(thumbImage);
                                int quality =Integer.parseInt("75");
                                quality = Math.max(0,Math.min(quality,100));
                                param.setQuality((float)quality / 100.0f,false);
                                encoder.setJPEGEncodeParam(param);
                                encoder.encode(thumbImage);
                                File file=new File("screencapture.jpg");
                                RandomAccessFile f=new RandomAccessFile(file,"r");
                                System.out.println("transmit len="+f.length());
                                byte [] data = new byte[(int)f.length()];
                                if(count++==0)
                                        dataone=new byte[data.length];
                                f.read(data);
                              
                if(dataone.length!=data.length)
                                {


                                    System.out.println("Transmitting");
                                    socket = new Socket("localhost",8080);
                                    ObjectOutputStream oos = new ObjectOutputStream(socket.getOutputStream());
                                    oos.writeObject(file);
                                }
                                dataone=data;
                                f.close();
                                file.delete();
                                main.sleep(2000);
                            }
                           
                      }
                }
                catch(Exception e)
                {
                     System.out.println("Errr in Imgcanvas thread "+e);
                }
               
               
        }
   
}


Monitor.java 


This code read the client scree and displays the screening images...


import java.awt.image.BufferedImage;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.*;
import java.awt.*;
import java.net.*;
import java.io.*;
import javax.imageio.ImageIO;
import java.awt.geom.*;
import javax.swing.*;


public class Monitor
{
    public static void main(String args[])throws Exception
    {
                JFrame f1=new JFrame();
                JLabel jl3=new JLabel();
        ServerSocket sck=new ServerSocket(8080);
                f1.setSize(400,300);
                f1.setVisible(true);
                        while(true)
                        {
                            f1.repaint();
                            Socket server=sck.accept();
                            ObjectInputStream entrada= new ObjectInputStream(server.getInputStream());
                            File file=(File)entrada.readObject();
                            Image image = ImageIO.read(file);
                            ImageIcon imgvar=new ImageIcon(image);
                            jl3.setIcon(imgvar);
                            f1.add(jl3);
                           
    }                    }
}

Wednesday, 6 April 2011

Contact for me

Contact 


Intha blog avulo periya blog oneum kedayathu.ithu just nera pohalanu create pannunathu.Itha manage pannave neram illa.Iruthallum etho Time passku blogs la ennala mudicha posta poadure.Enna Contact Pannura Azhavuku Nan onum Aulo periya appatakaru illa.Appadi enna contact pannanum Nu Nenachingana  ennanbenda1@gmail.com  ah Contact pannunga.

Welcomes
Nanbenda

Popular Posts

Disclaimer

This blog-spot does not host any files mentioned on this blog or on its own servers. He emphasized that to various links on the Internet that already exist and are uploaded by other websites or users there. Links to albums will be removed if a complaint with the artist or publisher.