How to add VM options to jar?

烂漫一生 提交于 2019-12-10 18:48:38

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!