I need to add -Djava.security.policy=myPolicyFile
so that my RMI jar would work. Or is there some other开发者_如何转开发 way to make that run?
If you're wanting to add the -D when someone launches your jar using java -jar
, that's not possible because it's not possible to specify JVM options inside the jar:
Can I set Java max heap size for running from a jar file?
That said, if you're in control of the process, you could use java.security.Policy.setPolicy
to manage the policy object yourself.
You can take a look here on how to use policy files. If you are using netbeans or some other IDE, you should be able to add
-Djava.security.policy=myPolicyFile
as an option to your VM, which is usually found somewhere within the project's properties.
精彩评论