Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. package example.hello;
  2.  
  3. import java.rmi.registry.Registry;
  4. import java.rmi.registry.LocateRegistry;
  5. import java.rmi.RemoteException;
  6. import java.rmi.server.UnicastRemoteObject;
  7.  
  8. public class Server implements Hello {
  9.  
  10. public Server() {}
  11.  
  12. public String sayHello() {
  13. return "Hello, world!";
  14. }
  15.  
  16. public static void main(String args[]) {
  17.  
  18. try {
  19. Server obj = new Server();
  20. Hello stub = (Hello) UnicastRemoteObject.exportObject(obj, 0);
  21.  
  22. // Bind the remote object's stub in the registry
  23. Registry registry = LocateRegistry.getRegistry();
  24. registry.bind("Hello", stub);
  25.  
  26. System.err.println("Server ready");
  27. } catch (Exception e) {
  28. System.err.println("Server exception: " + e.toString());
  29. e.printStackTrace();
  30. }
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement