我无论如何都不能用java rmi运行应用程序 我正在尝试运行经典的HelloWorld应用程序......
public static void main(String[] args) throws RemoteException, AlreadyBoundException, MalformedURLException {
System.setSecurityManager(new RMISecurityManager());
System.setProperty("java.security.policy","file://home/user/NetBeansProjects/RMI/server.policy");
Hello obj = new HelloImpl();
Registry registry = LocateRegistry.getRegistry();
registry.bind("Hello", obj);
System.out.println("Ready!");
}
我认为问题出现在这个政策文件中...我在google上找到了这个解决方案(创建这个策略文件)...但没有...
这是错误:
Exception in thread "main" java.security.AccessControlException: access denied ("java.util.PropertyPermission" "java.security.policy" "write")
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:366)
at java.security.AccessController.checkPermission(AccessController.java:560)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:549)
at java.lang.System.setProperty(System.java:781)
at rmi.Server.main(Server.java:22)
Java Result: 1
BUILD SUCCESSF
这是政策文件:
grant {
permission java.security.AllPermission;
};
但是从netbeans运行它我也手动启动rmiregistry?