Write client-server classes to calculate the sum of 1 + 2 + 3 + …+ n with rmi APIs for one client and one server.
kpecetWrite 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
Purchase the answer to view it
- project_3.zip
- BUS 520 WK 9 Assignment 4 Leadership Style
- science paper
- CRJ 325 MODULE 1 HOMEWORK
- Assignment 1: You should attempt both parts to this assignment Note: you should incorporate all sections of the various Acts/regulations where appropriate. Part 1: Case study Janet (taxpayer) residing in Australia is named as the sole beneficiary
- assignment 5
- MTH/221 Version 2 Week 4 Individual- Week Four Connect Exercises
- MTH/221 Version 2 Week 1 DQ 2
- for Professor Ryan
- Finc 440 and Finc 351 Week Three
- Research Paper on Active Shooter