Write client-server classes to calculate the sum of 1 + 2 + 3+ …+ n with rmi APIs for one client and one server. The calculationof sum must be written in a remote method in the server programs.The remote method should return the result of the sum method to theclient. The client calls the remote method of server to receive thesum. The client displays the sum on its console. Please copy/pasteyour java classes and interface under the word: Answer.Below are the programs’ skeleton and a sample dialog:The client class and interface:import java.rmi.Remote;//This interface is complete. Do not change it.public interface Project12ServerInterface extends Remote{public int calculateSum(int n ) throwsjava.rmi.RemoteException;}import java.rmi.*;import java.util.*;public class Assignment4Client{//Complete this class.}The server classes and interface:import java.rmi.Remote;//This interface is complete. Do not change it.public interface Assignment4ServerInterface extends Remote{public int calculateSum(int n ) throwsjava.rmi.RemoteException;}import java.rmi.*;import java.rmi.server.*;public class CalculateSumServerImpl extendsUnicastRemoteObject implements Assignment4ServerInterface {//Complete this class.}import java.rmi.*;import java.rmi.server.*;import java.rmi.registry.Registry;import java.rmi.registry.LocateRegistry;import java.net.*;public class Assignment4Server{//Complete this class.}A sample dialog:Display output on the server side:RMI registry cannot be located at port 16790RMI registry created at port 16790Hello Server ready.Display output on the client side:Enter a positive integer: 5Lookup completedThe sum is: 15Note: The green: 5 is what the user entered. So, it’s the sumof 1+2+3+4+5.If you enter 4, the sum should show 10 (sum of 1+2+3+4).Note: This is just a sample. Your project should work for anypositive integer for n.
Expert Answer
Answer to Write client-server classes to calculate the sum of 1 + 2 + 3 + …+ n with rmi APIs for one client and one server. The …