-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServer.java
More file actions
23 lines (19 loc) · 908 Bytes
/
Server.java
File metadata and controls
23 lines (19 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
//import java.rmi.AlreadyBoundException;
public class Server {
public static void main(String[] args) {
try {
ArithmeticImpl obj = new ArithmeticImpl();
Registry registry = LocateRegistry.createRegistry(1099);
registry.rebind("ArithmeticService", obj); // using rebind to avoid AlreadyBoundException
System.out.println("✅ RMI Server is running...");
System.out.println("🔗 ArithmeticService is bound to registry at port 1099.");
} catch (RemoteException e) {
System.err.println("❌ RemoteException occurred: " + e.getMessage());
} catch (Exception e) {
System.err.println("❌ Unexpected error: " + e.getMessage());
}
}
}