├── .gitignore ├── student-submission ├── BESE2018 │ ├── .gitignore │ ├── .DS_Store │ ├── bibek │ │ ├── ScreenShots │ │ │ ├── Client.png │ │ │ └── Server.png │ │ ├── MyInterface.java │ │ ├── MyImplementation.java │ │ ├── Server.java │ │ └── Client.java │ └── SagarGurung │ │ ├── ScreenShort │ │ └── Capture.JPG │ │ ├── MyInterface.java │ │ ├── MyImplementation.java │ │ ├── Server.java │ │ └── Client.java └── .DS_Store ├── .DS_Store └── rmi ├── javarmi-sample-01 ├── MyImplementation.java ├── MyInterface.java ├── Client.java └── Server.java └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.class -------------------------------------------------------------------------------- /student-submission/BESE2018/.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgrgug/distributed-system/HEAD/.DS_Store -------------------------------------------------------------------------------- /student-submission/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgrgug/distributed-system/HEAD/student-submission/.DS_Store -------------------------------------------------------------------------------- /student-submission/BESE2018/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgrgug/distributed-system/HEAD/student-submission/BESE2018/.DS_Store -------------------------------------------------------------------------------- /student-submission/BESE2018/bibek/ScreenShots/Client.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgrgug/distributed-system/HEAD/student-submission/BESE2018/bibek/ScreenShots/Client.png -------------------------------------------------------------------------------- /student-submission/BESE2018/bibek/ScreenShots/Server.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgrgug/distributed-system/HEAD/student-submission/BESE2018/bibek/ScreenShots/Server.png -------------------------------------------------------------------------------- /student-submission/BESE2018/SagarGurung/ScreenShort/Capture.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sgrgug/distributed-system/HEAD/student-submission/BESE2018/SagarGurung/ScreenShort/Capture.JPG -------------------------------------------------------------------------------- /rmi/javarmi-sample-01/MyImplementation.java: -------------------------------------------------------------------------------- 1 | public class MyImplementation implements MyInterface 2 | { 3 | public void printMsg() 4 | { 5 | System.out.println("Hello Implemented Class"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /rmi/javarmi-sample-01/MyInterface.java: -------------------------------------------------------------------------------- 1 | import java.rmi.Remote; 2 | import java.rmi.RemoteException; 3 | 4 | public interface MyInterface extends Remote 5 | { 6 | public void printMsg() throws RemoteException; 7 | } 8 | -------------------------------------------------------------------------------- /rmi/readme.md: -------------------------------------------------------------------------------- 1 | ## Usage 2 | 1. Compile all the .java files 3 | 4 | javac *.java 5 | 6 | 2. Start rmiregistry using following command 7 | 8 | start rmiregistry 9 | 10 | 3. Start Server code 11 | 12 | java Server 13 | 14 | OR 15 | 16 | if the following error occurs: "Error: Could not find or load main class" use 17 | 18 | java com.example.location.Server 19 | 20 | 4. Start Client code 21 | 22 | java Client 23 | 24 | 25 | -------------------------------------------------------------------------------- /student-submission/BESE2018/SagarGurung/MyInterface.java: -------------------------------------------------------------------------------- 1 | import java.rmi.Remote; 2 | import java.rmi.RemoteException; 3 | 4 | public interface MyInterface extends Remote 5 | { 6 | public void printMsg() throws RemoteException; 7 | // method to calculate the area of circle 8 | public void calculateAreaOfCircle(double radius) throws RemoteException; 9 | 10 | // calculate the tax amount 11 | public void calculateTax(double amount) throws RemoteException; 12 | 13 | // set the tax rate 14 | public void setTaxRate(double taxRate) throws RemoteException; 15 | 16 | // calculate the volume of rectangle 17 | 18 | public void calculateVolumeOfRectangle(double length, double breadth, double height) throws RemoteException; 19 | } -------------------------------------------------------------------------------- /student-submission/BESE2018/bibek/MyInterface.java: -------------------------------------------------------------------------------- 1 | import java.rmi.Remote; 2 | import java.rmi.RemoteException; 3 | 4 | public interface MyInterface extends Remote 5 | { 6 | public void printMsg() throws RemoteException; 7 | // method to calculate the area of circle 8 | public void calculateAreaOfCircle(double radius) throws RemoteException; 9 | 10 | // calculate the tax amount 11 | public void calculateTax(double amount) throws RemoteException; 12 | 13 | // set the tax rate 14 | public void setTaxRate(double taxRate) throws RemoteException; 15 | 16 | // calculate the volume of rectangle 17 | 18 | public void calculateVolumeOfRectangle(double length, double breadth, double height) throws RemoteException; 19 | } 20 | -------------------------------------------------------------------------------- /student-submission/BESE2018/SagarGurung/MyImplementation.java: -------------------------------------------------------------------------------- 1 | 2 | public class MyImplementation implements MyInterface 3 | { 4 | 5 | private double taxRate; 6 | 7 | public void printMsg() 8 | { 9 | System.out.println("Hello Implemented Class"); 10 | } 11 | 12 | public void calculateAreaOfCircle(double radius){ 13 | final double PI = 3.1415; 14 | System.out.println("The area of circle is " + PI * radius * radius ); 15 | } 16 | 17 | public void setTaxRate(double taxRate){ 18 | this.taxRate = taxRate; 19 | } 20 | 21 | public void calculateTax(double amount) { 22 | System.out.println("The tax amount is: " + amount * taxRate / 100) ; 23 | } 24 | 25 | public void calculateVolumeOfRectangle(double length, double breadth, double height) { 26 | 27 | System.out.println("The volume of rectangle is: " + length * breadth * height); 28 | } 29 | } -------------------------------------------------------------------------------- /student-submission/BESE2018/bibek/MyImplementation.java: -------------------------------------------------------------------------------- 1 | 2 | public class MyImplementation implements MyInterface 3 | { 4 | 5 | private double taxRate; 6 | 7 | public void printMsg() 8 | { 9 | System.out.println("Hello Implemented Class"); 10 | } 11 | 12 | public void calculateAreaOfCircle(double radius){ 13 | final double PI = 3.1415; 14 | System.out.println("The area of circle is " + PI * radius * radius ); 15 | } 16 | 17 | public void setTaxRate(double taxRate){ 18 | this.taxRate = taxRate; 19 | } 20 | 21 | public void calculateTax(double amount) { 22 | System.out.println("The tax amount is: " + amount * taxRate / 100) ; 23 | } 24 | 25 | public void calculateVolumeOfRectangle(double length, double breadth, double height) { 26 | 27 | System.out.println("The volume of rectangle is: " + length * breadth * height); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /rmi/javarmi-sample-01/Client.java: -------------------------------------------------------------------------------- 1 | import java.rmi.registry.LocateRegistry; 2 | import java.rmi.registry.Registry; 3 | 4 | public class Client 5 | { 6 | private Client() 7 | { 8 | 9 | } 10 | 11 | public static void main(String args[]) 12 | { 13 | try { 14 | // Getting the registry 15 | Registry registry = LocateRegistry.getRegistry("localhost"); 16 | 17 | // Looking up the registry for the remote object 18 | MyInterface stub = (MyInterface) registry.lookup("MyInterface"); 19 | 20 | // Calling the remote method using the obtained object 21 | stub.printMsg(); 22 | 23 | // System.out.println("Remote method invoked"); 24 | } catch(Exception e) { 25 | System.err.println("Client exception: " + e.toString()); 26 | e.printStackTrace(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /student-submission/BESE2018/SagarGurung/Server.java: -------------------------------------------------------------------------------- 1 | import java.rmi.registry.LocateRegistry; 2 | import java.rmi.registry.Registry; 3 | import java.rmi.server.UnicastRemoteObject; 4 | 5 | public class Server extends MyImplementation 6 | { 7 | public Server() 8 | { 9 | 10 | } 11 | 12 | public static void main(String args[]) 13 | { 14 | try { 15 | // Instantiating the implementation class 16 | MyImplementation imp = new MyImplementation(); 17 | 18 | // Exporting the object of implementation class 19 | // (here we are exporting the remote object to the stub) 20 | MyInterface stub = (MyInterface) UnicastRemoteObject.exportObject(imp, 8080); 21 | 22 | // Binding the remote object (stub) in the registry 23 | Registry registry = LocateRegistry.getRegistry(); 24 | 25 | registry.rebind("MyInterface", stub); 26 | System.err.println("Server ready"); 27 | } catch(Exception e) { 28 | System.err.println("Server exception: " + e.toString()); 29 | e.printStackTrace(); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /student-submission/BESE2018/bibek/Server.java: -------------------------------------------------------------------------------- 1 | import java.rmi.registry.LocateRegistry; 2 | import java.rmi.registry.Registry; 3 | import java.rmi.server.UnicastRemoteObject; 4 | 5 | public class Server extends MyImplementation 6 | { 7 | public Server() 8 | { 9 | 10 | } 11 | 12 | public static void main(String args[]) 13 | { 14 | try { 15 | // Instantiating the implementation class 16 | MyImplementation imp = new MyImplementation(); 17 | 18 | // Exporting the object of implementation class 19 | // (here we are exporting the remote object to the stub) 20 | MyInterface stub = (MyInterface) UnicastRemoteObject.exportObject(imp, 8080); 21 | 22 | // Binding the remote object (stub) in the registry 23 | Registry registry = LocateRegistry.getRegistry(); 24 | 25 | registry.rebind("MyInterface", stub); 26 | System.err.println("Server ready"); 27 | } catch(Exception e) { 28 | System.err.println("Server exception: " + e.toString()); 29 | e.printStackTrace(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /rmi/javarmi-sample-01/Server.java: -------------------------------------------------------------------------------- 1 | import java.rmi.registry.LocateRegistry; 2 | import java.rmi.registry.Registry; 3 | import java.rmi.server.UnicastRemoteObject; 4 | 5 | public class Server extends MyImplementation 6 | { 7 | public Server() 8 | { 9 | 10 | } 11 | 12 | public static void main(String args[]) 13 | { 14 | try { 15 | // Instantiating the implementation class 16 | MyImplementation imp = new MyImplementation(); 17 | 18 | // Exporting the object of implementation class 19 | // (here we are exporting the remote object to the stub) 20 | MyInterface stub = (MyInterface) UnicastRemoteObject.exportObject(imp, 8080); 21 | 22 | // Binding the remote object (stub) in the registry 23 | Registry registry = LocateRegistry.getRegistry(); 24 | 25 | registry.rebind("MyInterface", stub); 26 | System.err.println("Server ready"); 27 | } catch(Exception e) { 28 | System.err.println("Server exception: " + e.toString()); 29 | e.printStackTrace(); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /student-submission/BESE2018/SagarGurung/Client.java: -------------------------------------------------------------------------------- 1 | import java.rmi.registry.LocateRegistry; 2 | import java.rmi.registry.Registry; 3 | import java.util.*; 4 | 5 | public class Client 6 | { 7 | private Client() 8 | { 9 | 10 | } 11 | 12 | public static void main(String args[]) 13 | { 14 | try { 15 | // Getting the registry 16 | Registry registry = LocateRegistry.getRegistry("localhost"); 17 | 18 | // Looking up the registry for the remote object 19 | MyInterface stub = (MyInterface) registry.lookup("MyInterface"); 20 | 21 | // Calling the remote method using the obtained object 22 | stub.printMsg(); 23 | stub.calculateAreaOfCircle(21.0); 24 | stub.calculateVolumeOfRectangle(10.0, 12.0, 5.0); 25 | 26 | // System.out.println("Remote method invoked"); 27 | Scanner scanner = new Scanner(System.in); 28 | System.out.println("Enter the amount : "); 29 | double amount = scanner.nextDouble(); 30 | 31 | System.out.println("Enter the tax rate: "); 32 | double taxRate = scanner.nextDouble(); 33 | 34 | stub.setTaxRate(taxRate); 35 | stub.calculateTax(amount); 36 | 37 | } catch(Exception e) { 38 | System.err.println("Client exception: " + e.toString()); 39 | e.printStackTrace(); 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /student-submission/BESE2018/bibek/Client.java: -------------------------------------------------------------------------------- 1 | import java.rmi.registry.LocateRegistry; 2 | import java.rmi.registry.Registry; 3 | import java.util.*; 4 | 5 | public class Client 6 | { 7 | private Client() 8 | { 9 | 10 | } 11 | 12 | public static void main(String args[]) 13 | { 14 | try { 15 | // Getting the registry 16 | Registry registry = LocateRegistry.getRegistry("localhost"); 17 | 18 | // Looking up the registry for the remote object 19 | MyInterface stub = (MyInterface) registry.lookup("MyInterface"); 20 | 21 | // Calling the remote method using the obtained object 22 | stub.printMsg(); 23 | stub.calculateAreaOfCircle(21.0); 24 | stub.calculateVolumeOfRectangle(10.0, 12.0, 5.0); 25 | 26 | // System.out.println("Remote method invoked"); 27 | Scanner scanner = new Scanner(System.in); 28 | System.out.println("Enter the amount : "); 29 | double amount = scanner.nextDouble(); 30 | 31 | System.out.println("Enter the tax rate: "); 32 | double taxRate = scanner.nextDouble(); 33 | 34 | stub.setTaxRate(taxRate); 35 | stub.calculateTax(amount); 36 | 37 | } catch(Exception e) { 38 | System.err.println("Client exception: " + e.toString()); 39 | e.printStackTrace(); 40 | } 41 | } 42 | } 43 | 44 | --------------------------------------------------------------------------------