[go: up one dir, main page]

0% found this document useful (0 votes)
5 views3 pages

rmi Interface

Uploaded by

mr.dhanush.j
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

rmi Interface

Uploaded by

mr.dhanush.j
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

//RMI INTERFACE :

import java.rmi.*;

public interface MyInterface extends Remote

public String countInput(String input)throws RemoteException;

//RMI SERVER:

import java.rmi.*;

import java.rmi.server.*;

public class RMIServer extends UnicastRemoteObject implements MyInterface

public RMIServer()throws RemoteException

System.out.println("Remote Server is running Now.!!");

public static void main(String arg[])

try{

RMIServer p=new RMIServer();

Naming.rebind("rmiInterface",p);

catch(Exception e)

{ System.out.println("Exception occurred : "+e.getMessage()); }

}
@Override

public String countInput(String input) throws RemoteException

System.out.println("Received your input "+ input+" at server!!");

String reply;

reply="You have typed "+ input.length() +" letters!!";

return reply;

//RMI CLIENT :

import java.rmi.*;

import java.io.*;

public class RMIClient

public static void main(String args[])

try

{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

MyInterface p=( MyInterface)Naming.lookup("rmiInterface");

System.out.println("Type something...");

String input=br.readLine();

System.out.println(p.countInput(input));

catch(Exception e) {

System.out.println("Exception occurred : "+e.getMessage());

}
}

You might also like