A simple java client/server program to demonstrate RMI
Table of Contents
The goal was to write a java application using Java TCP API Socket to implement a simple client/server application using multi-threaded programming RMI.
The MathsTutor allows the user to practice arithmetic operations as chosen by the user. The user can select one of addition, subtraction, multiplication, or division.
On receiving the user’s choice from the client side, the server has to send randomly generated double digit numbers to the client. The MathsTutor has got method to create arithmetic problems using randomly generated double digit numbers.
On receiving the problem, the client has to display the problem and read the user input which is the answer consisting of an integer and send it to the server. The server has to invoke the method to execute the required operation, check the result and send a reply informing whether the answer is correct or incorrect to the client.
On completion of 10 problems, the server has to send a summary of results, and allow the user choose another arithmetic operation if desired. The user should be able to stop the service by entering a single character ‘Q’ or ‘q’.
First, make a directory to install the files to and change to that directory using :
$ mkdir mathstutor && cd mathstutor
Then all you need to do is clone the project from github into the directory by using :
$ git clone https://github.com/josh-privata/MathsTutor_RMI.git
Java Runtime is required to run the preceding commands.Note:
Initially the program needs to be compiled. After you have copied the *.java files to a directory, run the command :
$ javac *.java
Then run the program in a terminal window using the command :
$ java Server
And in a second terminal window use the command :
$ java Client