by Dinesh Thakur

The Java RMI comes along with Java JDK l.l and higher versions. It is a true distributed computing application interface for Java. Java RMI is language-specific, and can provide more advanced features like serialization, security and so on.

With the help of Java RMI, an object running in one NM can invoke the methods of an object running in another NM. Java RMI is language-specific and provides remote communication between programs written in the Java programming language. It is an Object Request Brokerage (ORB) but is Java-centric. It is based on the Java language object model and is best suited for communications between various Java objects. It handles all the details of the transport layer such as data encoding, transmission and retransmission and protocols. Methods belonging to objects running on other machines can be invoked, hence the name remote method invocation.

An object can invoke a method of another object, which exists in a different address space. The other address space could be on the same machine or on a different one. The RMI mechanism is in essence an object-oriented Remote Procedure Call (RPC) mechanism. There are three processes that participate in supporting remote method invocation.

• The Client process invokes a method on a remote object.

• The Server process owns the remote object. The remote object is an ordinary object in the address space of the server process.

• The third process is the Naming Registry, which is a naming service provided by the web servers to bind the remote object. Once it is bound with the name, it can be used to access the remote object. Examples of the naming service include JNDI and rmi registry. Two kinds of class can be used in Java RMI-remote classes and serializable classes. A Remote class is one whose instances can be used from a different address space. An object of a remote class can be referenced in two different ways:

• The object acts as an ordinary object within the address space where it was created, and can be used like any other object.

• Outside this address space, the object can only be referenced using an object handle. Though there are some limitations on using an object handle as compared to using the object itself, mostly, object handles are used in the same way as an ordinary object. An instance of a Remote class is called a remote object.

Another kind of class whose instances can be copied from one address space to another is called a Serializable class. An instance of a Serializable class will be called a serializable object. A serializable object is one that can be marshalled. Note that serializable in this context has no connection with the concept of serializability as used in the database management systems.

In RMI, when a serializable object is passed as a parameter, the value of the object is copied from one address space to another. On the contrary, if a remote object is passed as a parameter, then the object handle is copied from one address space to the other.