Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
vasanthgk02 authored Apr 11, 2022
1 parent ed77106 commit 0f83ffb
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
16 changes: 16 additions & 0 deletions client.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//CLIENT
import java.rmi.*;
public class client{
public static void main(String[] args){
try{
operation opt = (operation)Naming.lookup("rmi://localhost:6007/methods");
System.out.println(opt.getMessage());
System.out.println(opt.add(10, 20));
System.out.println(opt.subtract(10, 20));
System.out.println(opt.multiply(10, 20));
System.out.println(opt.divide(10, 20));
}
catch(Exception e){
}
}
}
9 changes: 9 additions & 0 deletions operation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//INTERFACE
import java.rmi.*;
public interface operation extends Remote{
public String getMessage() throws Exception;
public int add(int a, int b) throws Exception;
public int subtract(int a, int b) throws Exception;
public int multiply(int a,int b) throws Exception;
public int divide(int a, int b) throws Exception;
}
23 changes: 23 additions & 0 deletions operation_impl.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//INTERFACE IMPLEMENTATION
import java.rmi.server.*;
import java.rmi.*;
public class operation_impl extends UnicastRemoteObject implements operation{
public operation_impl() throws Exception{
super();
}
public String getMessage() throws Exception{
return "Welcome to RMI Implementation";
}
public int add(int a, int b) throws Exception{
return a + b;
}
public int subtract(int a, int b) throws Exception{
return a - b;
}
public int multiply(int a,int b) throws Exception{
return a * b;
}
public int divide(int a, int b) throws Exception{
return a / b;
}
}
17 changes: 17 additions & 0 deletions server.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//SERVER
import java.rmi.*;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
public class server{
public static void main(String args[]){
try{
Registry registry = LocateRegistry.createRegistry(6007);
operation_impl obj1 = new operation_impl();
registry.rebind("methods", obj1);
System.out.println("Server Ready!!");
}
catch(Exception e){
}
}
}

0 comments on commit 0f83ffb

Please sign in to comment.