Advance Java Experiment 05
Advance Java Experiment 05
Objective: Create a simple calculator application that demonstrates the use of RMI. You are not required to create
GUI.
Calculator.java
public CalculatorImpl()
throws java.rmi.RemoteException {
super();
}
CalculatorClient.java
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.net.MalformedURLException;
import java.rmi.NotBoundException;
import java.rmi.Naming;
public CalculatorServer() {
try {
Calculator c = new CalculatorImpl();
Naming.rebind("rmi://localhost:1099/CalculatorService", c);
} catch (Exception e) {
System.out.println("Trouble: " + e);
}
}
//Now use rmic to create the stub and skeleton class files.
> rmiregistry
o 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:
OUTPUT –
1
9
18
Poornima College of Engineering, Jaipur