|  Home   |  Contact Us   |  Online Exam   |  Tech World   |  Jobs    |  Member Login
Java Interview Questions
Jdbc Interview Questions
Servlet Interview Questions
Jsp Interview Questions
Struts Interview Questions
Ajax Interview Questions
Webservice Interview Questions
Designpattern Interview Questions
J2me Interview Questions
EJB Interview Questions
Spring Interview Questions
Hibernet Interview Questions
Enterprise IT Training
Java Program Examples
Ask Technical Expert!
Write Online Exam and Get Job Opportunity Here!
        Java Examples          
OOPS  |   Exception  |   RMI  |   String  |   Thread  |   io  |   Util  |   Net  |   AWT  |   JDBC  |  

RMI(REMOTE METHOD INVOCATION) PROGRAM:
1.RMI Interface Program
      import java.rmi.*;
     public interface Sint extends Remote {
     boolean eqtest(Object a) throws RemoteException;
     int add(int a,int b) throws RemoteException;
     String dsp(Object str) throws RemoteException;
     }
2.RMI Implementation Program
      import java.rmi.*;
     import java.rmi.server.*;
     public class Sintimp extends UnicastRemoteObject implements Sint {
     Sintimp()throws RemoteException {
     }
     public boolean eqtest(Object a) throws RemoteException {
     return true ;
     }
     public int add(int a,int b) throws RemoteException {
     return (a+b) ;
     }
     public String dsp(Object str) throws RemoteException {
     String s = (String) str ;
     return s.toUpperCase();
     }
     }
3.RMI Client Program
      import java.rmi.*;
     public class Crmi {
     public static void main(String[] args) {
     try {
     String url= "rmi://127.0.0.1/equal";
     Sint in = (Sint) Naming.lookup(url);
     System.out.println("The two Objects are : "+in.add(10,20));
     System.out.println("The String in Upper case : "+in.dsp("This will displays in Upper Case :"));
     }catch(Exception e) {
     e.printStackTrace();
     }
     }
     }
4.RMI Server Program
      import java.rmi.*;
     import java.net.*;
     public class Srmi {
     public static void main(String[] args)throws Exception {
     Sintimp rob = new Sintimp();
     Naming.rebind("equal",rob);
     System.out.println("Server is waiting for Client to Connect :");
     }
     }
Note:
     For Server Side:

     * javac Sint.java
     * javac Sintimp.java
     * javac Srmi.java
     * rmic Sintimp
     * start rmiregistry
     * java Srmi

For Client Side:

     * javac Crmi.java
     * java Crmi
Back to Top
All Rights Reserved : skdotcom technologies