简体   繁体   English

无法在我的系统上运行rmi注册表

[英]can't run rmi registry on my system

I am learning RMI concepts and had built a simple program taking reference from head first java . 我正在学习RMI概念,并已经构建了一个简单的程序,该程序从Java头开始就有参考。 All Went fine the first time i ran the code through command prompt. 第一次我通过命令提示符运行代码时,一切都很好。

the next time I ran code the command: 下次我运行命令代码时:

rmiregistry

took too long to load and nothing happened. 加载时间太长,没有任何反应。

I even tried the solution in this thread but nothing happend. 我什至在该线程中尝试了该解决方案,但没有任何反应。

need help to run RMI Registry 需要帮助来运行RMI注册表

also when i run my server and client file i get this error: 另外,当我运行服务器和客户端文件时,也会出现此错误:

Exception: java.rmi.ConnectException: Connection refused to host: 192.168.1.105; nested exception is:
    java.net.ConnectException: Connection refused: connect

My Source Code: 我的源代码:

myremote.java myremote.java

import java.rmi.*;

public interface myremote extends Remote
{
    public String sayhello() throws RemoteException;
}

Server.java 服务器.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);
        }   
    }
}

Can't run RMI registry on my system 无法在我的系统上运行RMI注册表

You've provided no evidence of that. 您没有提供任何证据。

took too long to load 加载时间太长

I don't know what this means. 我不知道这是什么意思。 Evidence? 证据?

nothing happened. 没啥事儿。

Nothing is supposed to happen. 什么都不会发生。 The RMI registry doesn't print anything. RMI注册表不显示任何内容。 It just sits there. 它只是坐在那里。

Run it and try again. 运行它,然后重试。 You'll be surprised. 您会感到惊讶。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM