> javac Calculator.java > javac CalculatorImpl.java > javac CalculatorServer.java > javac CalculatorClient.javaNow use rmic to create the stub and skeleton class files.
> rmic CalculatorImpl
You are now ready to run the system! You need to start three consoles, one for the server, one for the client, and one for the RMIRegistry.
Start with the Registry. You must be in the directory that contains the classes you have written. From there, enter the following:
If all goes well, the registry will start running and you can switch to the next console.
In the second console start the server hosting the
CalculatorService, and enter the following:
> java CalculatorServer
It will start, load the implementation into memory and wait for a client connection.
In the last console, start the client program.
> java CalculatorClient
If all goes well you will see the following output:
1 9 18 3
That's it; you have created a working RMI system. Even though you ran the three consoles on the same computer, RMI uses your network stack and TCP/IP to communicate between the three separate JVMs. This is a full-fledged RMI system.