-2
我在嘗試運行服務器時遇到此錯誤。我在security.policy中更新了我的政策。這是我的政策文件。java.security.AccessControlException:訪問被拒絕(「java.net.SocketPermission」「127.0.0.1:1099」「connect,resolve」)
grant codeBase "file:C:/.../workspace/RMIServerSide/bin/" {
permission java.security.Allpermission;
};
我的主要方法:
public static void main (String[] argv)throws RemoteException, MalformedURLException {
try {
System.setSecurityManager(new RMISecurityManager());
Addition Hello = new Addition();
Registry registry = LocateRegistry.createRegistry(1099);
Naming.rebind("localhost", Hello);
System.out.println("Addition Server is ready.");
}catch (Exception e) {
System.out.println("Addition Server failed: " + e);
}
}