Guest User

Untitled

a guest
Feb 24th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. package simplechat;
  2.  
  3. import java.io.IOException;
  4. import java.rmi.AccessException;
  5. import java.rmi.AlreadyBoundException;
  6. import java.rmi.RemoteException;
  7. import java.rmi.registry.LocateRegistry;
  8. import java.rmi.registry.Registry;
  9. import java.rmi.server.UnicastRemoteObject;
  10. import simplechat.common.ChatServer;
  11. import simplechat.common.Server;
  12.  
  13. /**
  14. *
  15. * @author Kadir Korkmaz
  16. */
  17. public class ServerApp {
  18.  
  19. public static void main(String[] args) throws IOException, RemoteException, AccessException, AlreadyBoundException {
  20.  
  21. System.out.println("Creating RMI registry");
  22. Runtime.getRuntime().exec("rmiregistry 2020");
  23. LocateRegistry.createRegistry(2020);
  24. System.out.println("Creating Server Object");
  25. Server chatServer = new Server();
  26. ChatServer serverStub = (ChatServer) UnicastRemoteObject.exportObject(chatServer, 0);
  27.  
  28. System.out.println("Registring Server object to registry");
  29. // Bind the remote object's stub in the registry
  30. Registry registry = LocateRegistry.getRegistry(2020);
  31. registry.bind("ChatServerObject", serverStub);
  32.  
  33. System.out.println("Server ready...");
  34.  
  35. }
  36.  
  37. }
Add Comment
Please, Sign In to add comment