Saturday, 24 May 2014
Interface
import java.rmi.Remote;
public interface calculator extends
Remote {
public long add(long a, long b) throws java.rmi.RemoteException;
public long sub(long a, long b) throws java.rmi.RemoteException;
public long mul(long a, long b) throws java.rmi.RemoteException;
public long div(long a, long b) throws java.rmi.RemoteException;
}
Server:-
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.server.UnicastRemoteObject;
import java.rmi.registry.Registry;
public class Rmicalc implements
calculator{
public long add(long a, long b) throws RemoteException {
return a+b; }
public long sub(long a, long b) throws RemoteException {
return a-b; }
public long mul(long a, long b) throws RemoteException {
return a*b; }
public long div(long a, long b) throws RemoteException {
return a/b; }
public static void main(String[] args) throws RemoteException {
Rmicalc rm=new Rmicalc();
calculator stub=(calculator) UnicastRemoteObject.exportObject(rm,0);
Registry reg=LocateRegistry.getRegistry();
reg.rebind("kkp", stub);
System.out.println("server
is ready");
}
Client:-
import java.lang.invoke.MethodHandles;
import java.rmi.NotBoundException;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class client {
public static void main(String s[]) throws RemoteException,
NotBoundException
{
Registry reg=LocateRegistry.getRegistry("localhost");
calculator skelton=(calculator)reg.lookup("kkp");
System.out.println();
System.out.println("Addition of 4 and 5 is :" + skelton.add(4,
5));
System.out.println("Substraction of 9 and 5 is :" +
skelton.sub(9, 5));
System.out.println("Multiplication of 8 and 3 is :" +
skelton.mul(8, 3));
System.out.println("Division of 16 and 4 is :" +
skelton.div(16, 4));
}
}
Related Post
CREATE A WEB APPLICATION TO STORE PERSON INFORMATION IN COOKIE AND DISPLAY IT BY READING FROM COOKIE USING SERVLET Login.html <html> <head>
Create an application which transfer file form server to client using UDP in JAVA Server.java package filetransfr; import java.io.*; import java.net.*; public class Filetran
DATABASE CONNECTIVITY USING JAVA JDBC = JAVA DATABASE CONNECTIVITY Using JDBC concept we can make a connection between java and
FREE CHAT SERVER MAKE USING JAVA ChatServer.java package chatting; import java.awt.*; import java.awt.event.*; import
CREATE A LOGIN APPLICATION USING SESSION USING SERVLET Login.java import java.io.IOException; import java.io.PrintWriter; import java.util.Enumeratio
RMI PROGRAM FOR OBJECT SERIALZATION Serialization is the process of converting an object into a sequence of bits so that it
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment
Click to see the code!
To insert emoticon you must added at least one space before the code.