我正在尝试一个基本的 RMI 示例。但是每当我运行该服务时,我都会收到以下错误
java.rmi.ConnectException: Connection refused to host: 116.203.202.217; nested exception is:
java.net.ConnectException: Connection timed out: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.bind(Unknown Source)
at java.rmi.Naming.bind(Naming.java:111)
at rmi.remote.RemteImpl.main(RemteImpl.java:29)
这是代码
package rmi.remote;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
public class RemteImpl extends UnicastRemoteObject implements RemoteIntf{
protected RemteImpl() throws RemoteException {
super();
// TODO Auto-generated constructor stub
}
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public String sayHello() throws RemoteException {
// TODO Auto-generated method stub
return "hi";
}
public static void main(String a[])
{
try {
RemoteIntf service=new RemteImpl();
Naming.bind("Remote",service);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
我正在使用 Windows 7 操作系统