There are several ways of developing distributed applications. RMI is also one way to transfer data from one host to another by using sockets RMI is a specification that enables Java Virtual Machine( JVM) to invoke methods inn an object located in another Java Virtual Machine( JVM). These two Java Virtual Machines( JVMs), could be running on different computer or running as separate process on the same computer. RMI is implemented on the middle-tier of the three-tier architecture framework, thereby facilitating the programmers to invoke distributed components across a networked environment. Sun introduced RMI as an easy alternative to complex coding invoked in server-socket programming . For using RMI, the programmer need not know socket programming or multi-threading and needs to solely concentration on the developing the business logic. Components of a Distributed RMI Application A Distributed RMI Application has TWO components RMI Server RMI Client The RMI server contains the object whose methods are to be invoked remotely. The server creates several remote objects and makes reference of these objects in the RMI registry. The RMI registry is a service that runs on the RMI server. The remote objects created by the server are registered by the objects’ unique name in this registry. The client gets the reference of one or more remote objects from the RMI registry by looking up the object name. The client then invoked the methods on the remote object(s) to access the services of the remote object(s) Server Object Objects Registered RMI Registry Searches for the remote Object Client Functioning of Applications in RMI The RMI Architecture The RMI architecture consists of three layers: Stub/Skeleton Layer Remote Reference Layer Transport Layer JVM JVM Client Server Stub Skeleton Remote Reference Layer Remote Reference Layer Transport Layer Transport Layer The RMI Architecture Stub/Skeleton Layer The Stub/Skeleton Layer listens to the method calls made by the client and redirects these to the remote RMI services on the server side. This layer consists of Stub and Skeleton. To invoke methods of the remote object, the request on the client- side starts with the Stub. A Stub is a client-side proxy representing the remote object. It is referred as any other local object by programs running on the client and provides methods of a remote object. The Stub communicates the method invocations to the remote object through a Skeleton that is implemented on to server. The Skeleton is a server-side proxy that communicates with the Stub by reading the parameters for the method call, making the call to the remote services implementation object, accepting the return value, and then writing the return value.