RMI (Remote Method Invocation) is a Java API for manipulating remote objects (e.g an object instantiated on another virtual machine, possibly on another machine on the network) in a transparent way, that is to say in the same way as if the object was located in the virtual machine (JVM) of the local machine.
Thus a server allows a client to remotely invoke methods on an instantiated object. Two virtual machines are needed (one for the server and the other on the client) and all communication is done in Java.
RMI is a Java based solution, unlike standard CORBA from OMG (Object Management Group) for manipulating remote objects, with any language. Corba is much more complicated to implement, this is the reason why many developers often turn to RMI.
The RMI layer structure
Connections and data transfers are performed by RMI in Java over TCP/IP using a proprietary protocol (JRMP, Java Remote Method Protocol) on port 1099.
As from Java 2 version 1.3, communication between client and server is done through RMI-IIOP (Internet Inter-Orb Protocol), a protocol standardized by the OMG (Object Management Group) and used in the CORBA .
Data transmission is done through a system of layers, based on the OSI model to ensure inter-operability between programs and versions of Java.
The stub and skeleton, are respectively located on the client and the server, ensure the conversion of communications made with the remote object.
The reference layer (RRL, remote Reference Layer) holds the localization system, to provide a way for objects to get a reference to the remote object (using the java.rmi.Naming package). It is generally known as RMI registry as it references the objects.
The transport layer can listen to incoming calls and to establish connections and transport of data over the network via TCP (java.net.Socket and java.net.SocketServer packages).
Thus, a client-server application based on RMI is implemented as three components:
The client application that implements the stub.
The application server that implements the skeleton.