问题
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?
回答1:
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.
回答2:
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.
来源:https://stackoverflow.com/questions/2893894/how-to-add-vm-options-to-jar