Home TechnologyProgrammingJava Subscribe to RSS

How Can I Use Class LocateRegistry To Manually Start RMI Registry?

Answer Question

1 Answer - Sort by: Date | Rating

    In RMI you can have references to "remote objects". These are objects that are on another computer but you interact with them as if they were local. The entity you get for an object remotely is actually not the object itself, but an interface that objects implements. The interface must extend java.rmi.Remote.An object can register itself with the RMI registry using the rebind method of java.rmi.Naming. (You have to start a local registry with rmiregistry first.) Objects can get a remote reference to a registered object using the lookup method of java.rmi.Naming.Now we get to try to write something fun using RMI. I give you the example to use class LocateRegistry to manually start RMI registry.
    Assume the port number is 2007, you may code as follows:  
    //in your server program  
    LocateRegistry.createRegistry (2007);
    Registry registry = LocateRegistry.getRegistry (2007);
    //in your client program
      Registry registry = LocateRegistry.getRegistry (2007);
    //If the RMI server is located somewhere, use:
      Registry registry = LocateRegistry.getRegistry (hostName, 2007);

    0 0

    Virgo 

    answered 3 years ago

      Answer Question - Answers are editable for 5 min.

      If you do not Sign-in or Register your answers will be anonymous,

      your answers may also be checked before going online.

      More

      More

         
         

        Ask a Question via Twitter

        Send a question to @askblurtit and we will publish it online and send you a reply everytime you receive an answer.

        Blurtit Store

        Get T-shirts, hoodies, caps and more at the Blurtit store

        Blurtit International