How to Run Java RMI?

11 Mar 2011 by

There is a tricky in getting Java RMI works and runs. First, you need to understand the Overview of Java RMI and know how to implement it. Java RMI relies on 3 components–client, server and registry service.

Note: This article refers to the code developed in How to Implement Java RMI.

Registry Service

There are 2 ways to deal with registry service.

  • Run rmiregistry command in Dos prompt or Console if it is not created in the code
  • Create RMI registry service in the code

Registry registry = LocateRegistry.createRegistry(1099);

    Server

    • It needs interface class(IPower.java) created in Step 1 of How to Implement Java RMI article
    • Run java PowerServer

    Client

    • It also needs interface class (IPower.java)
    • Be sure that you pointed to the right server’s registry service
    • Run java PowerClient

    No responses yet

    Leave a Reply