This repository contains a simple Remote Method Invocation (RMI) calculator application implemented in Java. The application allows clients to perform basic arithmetic operations remotely using RMI.
- Addition
- Subtraction
- Multiplication
- Division
- Java Development Kit (JDK)
- Git
-
Clone the repository:
git clone https://github.com/Shubham-Zone/Java-RMI-Calculator.git
-
Compile the Java files:
javac *.java
-
Start the RMI registry:
start rmiregistry
-
Run the server:
java CalculatorServer
-
Run the client:
java CalculatorClient
// Sample code for using the RMI Calculator
// Import the necessary packages
import rmi.Calculator;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class CalculatorClient {
public static void main(String[] args) {
try {
// Locate the RMI registry
Registry registry = LocateRegistry.getRegistry("localhost");
// Look up the remote object
Calculator calculator = (Calculator) registry.lookup("CalculatorService");
// Perform remote operations
double result = calculator.add(5, 3);
System.out.println("Addition Result: " + result);
} catch (Exception e) {
System.err.println("Client exception: " + e.toString());
e.printStackTrace();
}
}
}
- This project is inspired by the concepts of Remote Method Invocation (RMI) in Java.