-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed77106
commit 0f83ffb
Showing
4 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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){ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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){ | ||
} | ||
} | ||
} | ||
|