Wednesday, September 25, 2024
Google search engine
HomeLanguagesJavaCalculator Using RMI(Remote Method Invocation) in Java

Calculator Using RMI(Remote Method Invocation) in Java

RMI (Remote Method Invocation) is an API used to access objects running on another JVM(Server-side). It is mainly used for the creation of distributed systems and is provided in Java Rome. Stub and Skeleton are the two objects used for handling communication between client and server. The following figure shows an overview of RMI.

Working of RMI

Here,

  • Stub Object: The stub object on the client machine builds an information block and sends this information to the server.
  • Skeleton Object: The skeleton object passes the request from the stub object to the remote object. RMI contains a rmiregistry that holds all the server objects. The server binds all the objects to the registry and then the client fetches the object from the respective registry after which the client invokes the methods using the fetched objects.

Steps to create Calculator using RMI 

Step 1: Create the Remote interface

First, we will create 4 interfaces(addition, subtraction, multiplication, division). These interfaces are helpful for the operation. To create remote interfaces we need to extend the remote interface and the method prototype within the interface should throw the RemoteException.

AddI.java

 
RELATED ARTICLES

Most Popular

Recent Comments