IMPLEMENTATION OF REMOTE METHOD INVOCATION NETWORK JAVA PROGRAM - Computer Programming

Latest

C C++ Java Python Perl Programs Examples with Output -useful for Schools & College Students

Friday, October 29, 2010

IMPLEMENTATION OF REMOTE METHOD INVOCATION NETWORK JAVA PROGRAM

SERVER PROGRAM:

import java.rmi.*;
import java.rmi.server.*;
import java.io.*;
import java.lang.*;
public class rmiserver extends UnicastRemoteObject implements rmiinter
{
public rmiserver()throws RemoteException
{
}
public double add(double a1,double a2)throws RemoteException
{
return a1+a2;
}
public static void main(String arg[])throws Exception
{
rmiserver s=new rmiserver();
Naming.rebind("rmi://localhost:1099/test",s);
System.out.println("Registered");
}
}


CLIENT PROGRAM:

import java.rmi.*;
public class rmiclient
{

public rmiclient()throws RemoteException
{
}

public static void main(String arg[])throws Exception
{
rmiinter in=(rmiinter)Naming.lookup("rmi://localhost:1099/test");
double c=500.38;
double d=30.72;
System.out.println("The Sum is : "+in.add(c,d));
}
}


INTERFACE PROGRAM:

import java.rmi.*;
public interface rmiinter extends Remote
{
double add(double a,double b)throws RemoteException;
}



OUTPUT:

SERVER:


E:\bin>javac rmiserver.java

E:\bin>javac rmiinter.java

E:\bin>rmic rmiserver

E:\bin>start rmiregistry

E:\bin>java rmiserver

Registered

CLIENT:



E:\bin>javac rmiclient.java

E:\bin>java rmiclient

The Sum is : 531.1

E:\bin>

No comments:

Post a Comment