上运行RMI注册我学习RMI概念,已经建立了一个简单的程序,从采取基准喷墨头的第一个Java。所有在我第一次通过命令提示符运行代码时都很好。不能在我的系统
下一次我跑了代码的命令:
rmiregistry
花了太长时间来加载和什么都没有发生。
我甚至尝试在这个线程解决方案,但没有happend。
还当我跑我的服务器和客户端文件,我得到这个错误:
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;
}
Server.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);
}
}
}
client.java
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);
}
}
}
你的意思是什么由“花了太长时间来加载”?而'没有发生'?而不是什么? – EJP