Search code examples
javarmi

HelloRMIServer cannot connect in bind()


Doing a course, and I am trying to wrap my head around RMI. I cant seem to get it right. Link to unmodified source code: https://drive.google.com/open?id=0B7NQABLlsgGWbXNhb0JHall4NXM

package helloworld;

import java.rmi.Naming;

public class HelloRMIServer {

// TODO 08. Set the OBJECT_NAME to the same value used by the client.
private static String OBJECT_NAME = "TEST";

public static void main(String[] args) {
    try {
        // TODO 09. Create a new instance of the remote object.
        MessageInterface message = new MessageInterface();
        // TODO 10. Re-bind the object in the registry.
        Naming.rebind("rmi://" + "127.0.0.1" + "/" + OBJECT_NAME, message);
        System.out.println("Server object message bound into registry.");
    } catch (Exception e) {
        e.printStackTrace();
    }
    System.out.println("Server done creating and binding objects.");
    }
}

What am I doing wrong?


Solution

  • You haven't started the rmiregistry.