Remote Method Invocation

Kumuditha Gimnath
1 min readJul 18, 2020

--

RMI stands for Remote Method Invocation. It is a mechanism that allows an object residing in one system (JVM) to access/invoke an object running on another JVM. RMI is used to build distributed applications; it provides remote communication between Java programs. It is provided in the package java.rmi.

  1. Create the remote interface

Here, we are creating a remote interface that extends the Remote interface. There are two methods add and multiply declares RemoteException.

2. Provide the implementation of the remote interface

Next provide the implementation of the remote interface. So that need to extend the UnicastRemoteObject class.

3. create the stub and skeleton objects using the rmic tool.

The rmic tool invokes the RMI compiler and creates stub and skeleton objects.

rmic CalculationRemote

4. Start the registry service by the rmiregistry tool.

start the registry service by using the rmiregistry tool. so that it using the port number 5000.

rmiregistry 5000

5. Create and run the server application

6. Create and run the client application.

7. Output of the server and client application.

--

--