group-icon
Java Developers
Group for Java developers and programmers. Ask questions and get answers related to Java programming
271 Members
Join this group to post and comment.
DHIRAJ LOTLIKAR
DHIRAJ LOTLIKAR
Information Technology
04 Feb 2019

What is remote method invocation in java?

Remote Method Invocation (RMI) is an API which allows an object to invoke a method on an object that exists in another address space, which could be on the same machine or on a remote machine. Through RMI, object running in a JVM present on a computer (Client side) can invoke methods on an object present in another JVM (Server side). RMI creates a public remote server object that enables client and server side communications through simple method calls on the server object.

Working of RMI

The communication between client and server is handled by using two intermediate objects: Stub object (on client side) and Skeleton object (on server side).

Stub Object

The stub object on the client machine builds an information block and sends this information to the server. 

The block consists of

1)An identifier of the remote object to be used

2)Method name which is to be invoked

3)Parameters to the remote JVM

Skeleton Object

The skeleton object passes the request from the stub object to the remote object. It performs following tasks

1) It calls the desired method on the real object present on the server.

2) It forwards the parameters received from the stub object to the method.

Steps to implement Interface

  1. Defining a remote interface
  2. Implementing the remote interface
  3. Creating Stub and Skeleton objects from the implementation class using rmic (rmi complier)
  4. Start the rmiregistry
  5. Create and execute the server application program
  6. Create and execute the client application program.

Remote file