RMI Remote Method Invocation and its Component

What is RMI? Explain the purpose of it's each component with the help of examples.

The RMI (Remote Method Invocation) is an API that provides a mechanism to create distributed applications in java. The RMI allows an object to invoke methods on an object running in another JVM. The RMI provides remote communication between the applications using two objects stub and skeleton.

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.

The architecture of an RMI Application

In an RMI application, we write two programs, a server program (resides on the server) and a client program (resides on the client).

  • Inside the server program, a remote object is created, and a reference of that object is made available for the client (using the registry).
  • The client program requests the remote objects on the server and tries to invoke its methods.

let us now discuss the components of this architecture.


  • Transport Layer − This layer connects the client and the server. It manages the existing connection and also sets up new connections.
  • Stub − A stub is a representation (proxy) of the remote object at the client. It resides in the client system; it acts as a gateway for the client program.
  • Skeleton − This is the object which resides on the server-side. stub communicates with this skeleton to pass requests to the remote object.
  • RRL(Remote Reference Layer) − It is the layer that manages the references made by the client to the remote object.

Working of an RMI Application

The following points summarize how an RMI application works

  • When the client makes a call to the remote object, it is received by the stub which eventually passes this request to the RRL.
  • When the client-side RRL receives the request, it invokes a method called invoke() of the object remoteRef. It passes the request to the RRL on the server-side.
  • The RRL on the server-side passes the request to the Skeleton (proxy on the server) which finally invokes the required object on the server.
  • The result is passed all the way back to the client.
See Enterprice Application Punjab University Solved Past Paper 2020

Get updates in your Inbox
Subscribe