[英]can't run rmi registry on my system
我正在学习RMI概念,并已经构建了一个简单的程序,该程序从Java头开始就有参考。 第一次我通过命令提示符运行代码时,一切都很好。
下次我运行命令代码时:
rmiregistry
加载时间太长,没有任何反应。
我什至在该线程中尝试了该解决方案,但没有任何反应。
另外,当我运行服务器和客户端文件时,也会出现此错误:
Exception: java.rmi.ConnectException: Connection refused to host: 192.168.1.105; nested exception is:
java.net.ConnectException: Connection refused: connect
我的源代码:
myremote.java
import java.rmi.*;
public interface myremote extends Remote
{
public String sayhello() throws RemoteException;
}
服务器.java
import java.rmi.*;
import java.rmi.server.*;
public class Server extends UnicastRemoteObject implements myremote
{
public Server() throws RemoteException{}
public String sayhello()
{
return("Server says hi");
}
public static void main(String args[])
{
try
{
myremote S = new Server();
Naming.rebind("remotehello",S);
}
catch(Exception E)
{
System.out.println("Exception: "+E);
}
}
}
客户端程序
import java.rmi.*;
public class client
{
public static void main(String[] args)
{
client c = new client();
c.go();
}
public void go()
{
try
{
myremote S=(myremote) Naming.lookup("rmi://127.0.0.1/remotehello");
System.out.println("Output:"+S.sayhello());
}
catch(Exception E)
{
System.out.println("Exception: "+ E);
}
}
}
无法在我的系统上运行RMI注册表
您没有提供任何证据。
加载时间太长
我不知道这是什么意思。 证据?
没啥事儿。
什么都不会发生。 RMI注册表不显示任何内容。 它只是坐在那里。
运行它,然后重试。 您会感到惊讶。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.