Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法为位于我想要的任何位置的 Java SecurityManager 创建自定义策略文件?如果是,我将如何做到这一点,以及如何以编程方式将 SecurityManager 绑定到该文件,而不是通过命令行?
java.security.policy您可以通过JVM 参数指定其他安全策略文件:
java.security.policy
java -Djava.security.policy=<path to policy file> MyClass
如果您希望策略文件完全覆盖系统和默认用户策略文件,请指定 'double =' 语法:
java -Djava.security.policy==<path to policy file> MyClass