What is RMI?
Remote Method Invocation (RMI) facilitates object function calls between Java Virtual Machines (JVMs). JVMs can be located on separate computers yet one JVM can invoke methods belonging to an object stored in another JVM. Methods can even pass objects that a foreign virtual machine has never encountered before, allowing dynamic loading of new classes as required.
Basic Steps to Write your Own RMI Service
How to Run?
You just need to register your RMI service with your operating system.
HOW?
Following are the steps to register and run RMI Service.
Start RMI Registry :
To start the registry, Windows users should do the following (assuming that your java\bin directory is in the current path)
start rmiregistry
To start the registry, Unix users should do the following
rmiregistry &
Compile the Server
Compile the server, and use the rmic tool to create stub files.
Start the Server
From the directory in which the classes are located, type the following
java PowerServiceSer ver
Start the Client
You can run the client locally, or from a different machine. In either case, you'll need to specify the hostname of the machine where you are running the server. If you're running it locally, use localhost as the hostname.
java PowerServiceCli ent localhost
I have attached a simple RMI example :)
Regards
ARUZ
Remote Method Invocation (RMI) facilitates object function calls between Java Virtual Machines (JVMs). JVMs can be located on separate computers yet one JVM can invoke methods belonging to an object stored in another JVM. Methods can even pass objects that a foreign virtual machine has never encountered before, allowing dynamic loading of new classes as required.
Basic Steps to Write your Own RMI Service
- Writing RMI Server
- Writing an Interface
- Implementing the Interface
- Writing RMI Client
How to Run?
You just need to register your RMI service with your operating system.
HOW?
Following are the steps to register and run RMI Service.
- Start RMI Registry
- Compile the Server and Client
- Start the Server and Client
Start RMI Registry :
To start the registry, Windows users should do the following (assuming that your java\bin directory is in the current path)
start rmiregistry
To start the registry, Unix users should do the following
rmiregistry &
Compile the Server
Compile the server, and use the rmic tool to create stub files.
Start the Server
From the directory in which the classes are located, type the following
java PowerServiceSer ver
Start the Client
You can run the client locally, or from a different machine. In either case, you'll need to specify the hostname of the machine where you are running the server. If you're running it locally, use localhost as the hostname.
java PowerServiceCli ent localhost
I have attached a simple RMI example :)
Regards
ARUZ
Comment