Running Java Security Manager without the default java.policy file

前端 未结 1 1782
旧时难觅i
旧时难觅i 2021-02-10 11:17

I don\'t want to modify anything in my java home directory, however, I am afraid that sometimes my default java.policy file may be too permissive. Is there a way for me to use a

1条回答
  •  清歌不尽
    2021-02-10 11:53

    A Common Mistake with Java SecurityManager:

    • To run with SecurityManager and default Java security policy, which is $JAVA_HOME/jre/lib/security/java.policy:

      java -Djava.security.manager Main

    • To run with SecurityManager and only your custom security policy (ignoring default java security policy):

      java -Djava.security.manager -Djava.security.policy==security.policy Main

    • To run with SecurityManager and default java security policy first, then your custom security policy:

      java -Djava.security.manager -Djava.security.policy=security.policy Main

    • If you don't want a SecurityManager, then simply leave out java.security.policy to avoid any confusion.

    0 讨论(0)
提交回复
热议问题