[英]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.