// Sample6/App.java //########################################################## // App Implementation // (*) Uses RMI server interface AclassRI // (*) main() configured to set Security Manager // (*) Connects to rmiregistry using local loop back (127.0.0.1) //########################################################## // // import java.rmi.*; public class App { public App() { try { A = (AclassRI)Naming.lookup("rmi://127.0.0.1/AclassRS"); } catch (Exception e) { System.out.println("Exception: " + e.getMessage()); e.printStackTrace(); } } public int doCalculation(int D) { try { return A.addTwo(D); // Call an Aclass method } catch (RemoteException e) { System.out.println("RemoteException: " + e.getMessage()); e.printStackTrace(); } return 0; } //#### DATA MEMBERS #### AclassRI A; public static void main(String argv[]) { System.setSecurityManager(new RMISecurityManager()); App S = new App(); int result = S.doCalculation(5); System.out.println("The result of the calculation = " + result+ " (and should = 7)"); } }