Write client-server classes to calculate the sum of 1 + 2 + 3 + …+ n with rmi APIs for one client and one server.

profilekpecet

Write client-server classes to calculate the sum of 1 + 2 + 3 + …+ nwith rmi APIs for one client and one server. The calculation of sum must be written in a remote method in the server programs. The remote method should return the value of: sum to the client. 

The client calls the remote method of servers to receive the sum. The client displays the sum on its console. Please copy/paste your 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.

publicinterface Project3ServerInterface extends Remote {

 

  publicint calculateSum(int n ) throws java.rmi.RemoteException;

}

 

import java.rmi.*;

import java.util.*;

 

public class Project3Client{

  //Complete this class.

}

 

The server classes and interface:

 

import java.rmi.Remote;

//This interface is complete. Do not change it.

publicinterface Project3ServerInterface extends Remote {

 

  publicint calculateSum(int n ) throws java.rmi.RemoteException;

}

 

 

import java.rmi.*;

import java.rmi.server.*;

 

publicclassCalculateSumServerImplextends UnicastRemoteObject implements Project3ServerInterface {

  //Complete this class.

}

 

 

import java.rmi.*;

importjava.rmi.server.*;

import java.rmi.registry.Registry;

import java.rmi.registry.LocateRegistry;

importjava.net.*;

 

publicclass Project3Server{

  //Complete this class.

}

 

A sample dialog:

Display output on the server side:

 

RMI registry cannot be located at port 16790

RMI registry created at port 16790

Hello Server ready.

 

Display output on the client side:

 

Enter a positive integer: 5

Lookup completed 

The sum is: 15

 

Note: The green: 5 is what the user entered.

Note: This is just a sample. Your project should work for any positive integer for n.

 

Answer:

 

The server classes and interface:

 

 

 

The client class and interface:

    • 9 years ago
    • 50
    Answer(1)

    Purchase the answer to view it

    blurred-text
    NOT RATED
    • attachment
      project_3.zip
    Bids(1)