Java Tutorial
Operators
Flow Control
String
Number and Date
Built-in Classes
Array
Class and Object
Inheritance and Polymorphism
Exception Handling
Collections, Generics and Enumerations
Reflection
Input/Output Stream
Annotation
Remote Method Invocation (RMI) is a Java technology that allows objects residing in different JVMs (Java Virtual Machines) to invoke each other's methods as if they were in the same JVM. RMI uses Java's reflection mechanism to dynamically discover and invoke methods on remote objects at runtime.
Reflection is a feature in Java that allows programs to examine and manipulate their own behavior during runtime. It enables the discovery of information about classes, interfaces, fields, and methods at runtime, without knowing their names at compile time. RMI uses reflection to achieve the following:
Here's a brief overview of how RMI utilizes reflection:
MyRemoteObject remoteObject = new MyRemoteObject(); Naming.rebind("rmi://localhost/RemoteObject", remoteObject);
MyRemoteInterface remoteObject = (MyRemoteInterface) Naming.lookup("rmi://localhost/RemoteObject");
int result = remoteObject.myRemoteMethod(param1, param2);
In conclusion, RMI in Java uses the reflection mechanism to enable remote method invocation between objects residing in different JVMs. Reflection allows RMI to dynamically discover and invoke methods on remote objects, thus facilitating communication between distributed applications.