用java编写RMI程序,调试时出现access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve),看过全部贴子了,没有解决
我已经把整个论坛的关于RMI的贴子看了一遍,按照里面的方法试了,都不行。
下面,我描述一下问题:
系统: win2000 jb6企业版
hello.java //interface file
package testrmi_v3;
import java.rmi.*;
public interface hello extends Remote{
public String sayhello() throws RemoteException;
}
helloimpl.java //implement file
package testrmi_v3;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
import java.security.SecurityPermission;
import java.net.*;
public class helloimpl extends UnicastRemoteObject implements hello{
public helloimpl() throws RemoteException
{
super();
}
public String sayhello() throws RemoteException
{
return "hello , how are you";
}
}
helloserver.java //server file
package testrmi_v3;
import java.net.*;
import java.rmi.*;
import java.lang.*;
import java.rmi.server.UnicastRemoteObject;
public class helloserver {
public static void main(String args[])
{
System.setSecurityManager(new RMISecurityManager());
try
{
helloimpl obj=new helloimpl();
Naming.rebind("rmi://127.0.0.1:1099/helloserver",obj);
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}
}
helloclient.java //client file
package testrmi_v3;
import java.rmi.*;
import java.rmi.server.*;
import java.net.*;
public class helloclient {
public static void main(String args[])
{
System.setSecurityManager(new RMISecurityManager());
try
{
helloimpl myhello=(helloimpl)Naming.lookup("//127.0.0.1/helloserver");
System.out.println(myhello.sayhello());
}
catch(Exception e)
{
System.out.println(e.toString());
}
}
}
hello.policy //policy file
grant{
//allow all permission
permission java.security.AllPermission;
};
完全是照着jb6的help做的
而且有运行参数-Djava.rmi.server.codebase=file:d:\jubuilder6\myprogram\testrmi_v3\classes\-Djava.security.policy=file:d:\jbuilder6\myprogram\testrmi_v3\hello.policy
出现的问题是:access denied (java.net.SocketPermission 127.0.0.1:1099 connect,resolve)
我觉得应该是权限设置的不对,但我又说不出那里不对,请指教