程序中把一个对象绑定在一个机器上,却说access denied ,为什么

解决方案 »

  1.   

    写一个java.policy的文件,内容如下,放在C:\Documents and Settings\Administrator(如果你是Administrator登陆的)目录下
    grant {
            permission java.security.AllPermission;
    };
      

  2.   

    指定了policy文件后,可以连接成功了
    运行时报
    HelloImpl err: RemoteException occurred in server thread; nested exception is: 
    java.rmi.UnmarshalException: error unmarshalling arguments; nested exception is: 
    java.lang.ClassNotFoundException: examples.hello.HelloImpl_Stub可这个examples.hello.HelloImpl_Stub已经生成了
      

  3.   

    打成jar包,指定你的codebase指向这个jar.注意HelloImpl_Stub一定要包含在内
    在jbulider工程run 属性加上:java -D codebase=你的jar
    大概是这样,细节可能不对
      

  4.   

    两种解决方法:
    1.在程序启动注册服务,并指定到RMI端口。
    HelloImpl  server = null;
    try
    {      
       java.rmi.registry.LocateRegistry.createRegistry(35687);
       server = new HelloImpl();
       Naming.rebind("//192.168.0.120:35687/HelloServer",server);
      
            }
            catch(Exception x)
            {
                x.printStackTrace();
            }2.用jvm默认端口,但必需运行rmiregistry后,才能运行你的RMI程序。