如何解决java程序中的java.rmi.ConnectException?

如何解决java程序中的java.rmi.ConnectException?,java,sockets,rmi,Java,Sockets,Rmi,我创建了一个简单的JavaRMI程序来理解它是如何工作的 编辑:我们正在使用代理连接… Remote exception: java.rmi.ConnectException: Connection refused to host: 10.7.150.18; nested exception is: java.net.ConnectException: Connection refused: connect 这是我的服务器端代码供您参考 import java.rmi.*; impo

我创建了一个简单的JavaRMI程序来理解它是如何工作的

编辑:我们正在使用代理连接…

 Remote exception: java.rmi.ConnectException: Connection refused to host: 10.7.150.18; nested exception is: 
   java.net.ConnectException: Connection refused: connect
这是我的服务器端代码供您参考

import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;

public class SampleServerImpl extends UnicastRemoteObject implements SampleServer
{
  SampleServerImpl() throws RemoteException
  {
     super();
  }
    @Override
  public int sum(int a,int b) throws RemoteException
  {
     return a + b;
  }

    public static void main(String[] args)
    {
      try
      {
        //set the security manager  
        //System.setSecurityManager(new RMISecurityManager());
        //create a local instance of the object
        SampleServerImpl Server = new SampleServerImpl();
        //put the local instance in the registry
        Naming.rebind("//10.7.150.18:9999" , Server);
        System.out.println("Server waiting.....");
      }
      catch (java.net.MalformedURLException me) 
      {
        System.out.println("Malformed URL: " + me.toString());  
      }
      catch (RemoteException re)
      {
         System.out.println("Remote exception: " + re.toString()); 
      }    
    }
}

请指导我摆脱这个问题…

命名类提供了在远程对象注册表中存储和获取远程对象引用的方法。命名类的每个方法都将一个名称作为其参数之一,该名称是URL格式(不含scheme组件)的java.lang.String,格式如下:

//host:port/name
在URL格式中添加带有的名称

//10.7.150.18:9999/Server

:我们正在代理环境中使用RMI。这会导致代理环境中出现问题吗?我无法完全理解这一点。您的服务器和客户端是否可以相互访问?或者你的意思是说你使用代理服务器访问你的服务器?@事实上,我们的校园通过代理设置完全限制了互联网访问。所以,现在我使用的客户端和服务器机器都在同一个校园中。服务器机器和客户端机器都在代理设置下工作。我现在做什么?那么要访问互联网,您使用一些代理服务器,但为了访问服务器和客户机,您不使用任何代理…无论如何,即使有防火墙或任何代理,请参考以下链接,这里也没有回答问题的内容-1.提供的资料不足。你在装订时收到这个吗?什么时候抬头?或者在执行远程方法时?@EJP:当使用java.exe运行此文件时,实际上并没有回答我的问题,答案就在您应该发布的stacktrace中,但如果您的意思是在绑定时发生,则意味着RMI注册表没有在端口9999的主机上运行。