如何向jar添加VM选项? [英] How to add VM options to jar?
问题描述
我需要添加-Djava.security.policy = myPolicyFile以便我的RMI jar可以工作。或者还有其他一些方法可以让它运行吗?
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?
推荐答案
如果你想在有人发布你的时候添加-D使用 java -jar
的jar,这是不可能的,因为它无法在jar中指定JVM选项:
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:
< a href =https://stackoverflow.com/questions/1018217/can-i-set-java-max-heap-size-for-running-from-a-jar-file>我可以设置Java最大堆大小吗?从jar文件运行?
这就是说,如果你控制了这个过程,你可以使用 java。 security.Policy.setPolicy
自己管理策略对象。
That said, if you're in control of the process, you could use java.security.Policy.setPolicy
to manage the policy object yourself.
这篇关于如何向jar添加VM选项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!