What Does Java Remote Method Invocation Mean?
Java Remote Method Invocation (Java RMI) is a mechanism that allows one Java Virtual Machine (JVM) running object to invoke methods on an object running in another JVM. It facilitates the remote calling of Java object methods and sharing of resources and services.
Techopedia Explains Java Remote Method Invocation
Java RMI is a technological mechanism in which a server and client communicate and pass information while relying on the Java Remote Method Protocol (JRMP). Java relies heavily on Java object serialization, which allows the transmission of objects as a stream. RMI also allows a client and server to load new object types dynamically, as required.
RMI uses layered architecture:
- Application layer
- Stub and skeleton layer
- Remote reference layer
- Transport layer
Java RMI has numerous advantages, as follows:
- Portable to any JVM
- Part of Java’s write once run anywhere (WORA) approach
- Safe and secure: Uses built-in Java security mechanisms to facilitate system safety during user download implementations
- Easy to write/Easy to maintain: Facilitates write remote Java servers and Java clients that access those servers
Consider this scenario: User A creates a class, which has methods that provide a specific service. User B wants to user A’s service. Through Java RMI, user B is able to invoke the object’s method. User A places the service in the registry. User B is unaware of the service location, so it invokes the RMI registry. The registry then locates the service, which invokes the method.