HelloRMIServer 无法在 bind() 中连接
HelloRMIServer cannot connect in bind()
正在上一门课程,我正在努力研究 RMI。我似乎做对了。 Link 到未修改的源代码: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.");
}
}
我做错了什么?
您还没有开始rmiregistry
。
正在上一门课程,我正在努力研究 RMI。我似乎做对了。 Link 到未修改的源代码: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.");
}
}
我做错了什么?
您还没有开始rmiregistry
。