RMI means Java Remote Method Invocation. This project is a demo to show how RMI works.
RMI contains three parts :
- client
- server
- registry
A RMI server provides some services which can be registered into a RMI registry. Then, a RMI client finds the service it want by asking registry , and use the service if it exists.
We can create a RMI registry by calling method createRegistry
, or using
rmiregistry
command. However, you will get ClassNotFound
error if you
use rmiregistry
command directly, because a rmi registry must load the classes
which is declared remoting. java.rmi.server.codebase
property can be used to solve
the problem. (Unfortunately, I never do it successfully.🙃)
Actually, some applications create registry on the server machine. That is, registry and server are usually running in a same JVM.
Client program must use remoting interface by adding a dependency of the jar file. IP and port are used to recognized the service's address. So, client invokes the remoting service by indicating IP and port.