Opening the book…
Remote Method Invocation
Remote Method Invocation (RMI) is a distributed object system specific to Java. RMI allows an object running in one Java Virtual Machine (JVM) to invoke methods on an object in another JVM, seamlessly [1]. The technology is Java-native and leverages Java’s object serialization for transmitting parameters and return values. RMI essentially extends RPC semantics to object-oriented Java: you define a remote interface (an Java interface that extends java.rmi.Remote), implement it on the server, and then clients can obtain a stub/proxy to the remote object (often via an RMI registry) and invoke methods. The RMI runtime handles communication over TCP (by default using Java Remote Method Protocol, JRMP).
How RMI Works:
To build an RMI application, developers follow steps similar to RPC but in Java terms:
- Define a remote interface (declaring the methods that can be called remotely, each throwing RemoteException).
- Implement the remote interface in a server class (which typically extends UnicastRemoteObject to allow remote invocation).
- Start an RMI registry and deploy the server object, binding it to a name in the registry.
- Lookup the remote object on the client via the registry to get a stub.
- Invoke methods on the stub as if it were a local object – the RMI infrastructure will transmit the call to the server and return results.
Under the hood, RMI generates stubs and skeletons (in Java <=1.4, skeletons were used; later versions generate stubs dynamically). The stub on the client side forwards method calls to the remote JVM, and the skeleton on the server side dispatches calls to the actual implementation. The parameters are passed either by value (serialized copies of objects) or by remote reference (if the parameter is itself a remote object). RMI includes features like distributed garbage collection (to auto-release remote objects when not referenced) and dynamic class loading (if the client needs the definition of a custom object returned from server, it can download the bytecode from a provided codebase).
Advantages and Limitations:
RMI’s advantages include seamless integration with Java (the developer can use Java objects and interfaces naturally) and built-in garbage collection of remote objects. It abstracts networking to a large extent. However, RMI is limited to Java – both client and server must be written in Java and running a JVM. This tight coupling to Java means RMI is not suitable for heterogeneous environments where different languages need to communicate. Furthermore, RMI’s portability is limited by the need for a common Java version and the security constraints (it may require policy files and security managers for certain operations). Because of these limitations, RMI is primarily used in Java-centric systems. In modern cloud environments that embrace polyglot services, RMI has largely been superseded by more language-neutral approaches (like REST or gRPC), but it laid important groundwork in distributed object design.

This page titled 7.1.2: Remote Method Invocation (RMI) was last modified on Tue, 22 Sep 2026 23:48:49 GMT and is shared under a CC BY 4.0 license and was authored, remixed, and/or curated by Felix Amoruwa.
The book could not be loaded just now.