如何将VM选项添加到jar文件中?

发布于 2024-09-02 06:27:33 字数 94 浏览 3 评论 0原文

我需要添加 -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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

人生戏 2024-09-09 06:27:33

如果您想在有人使用 java -jar 启动您的 jar 时添加 -D,这是不可能的,因为无法在 jar 内指定 JVM 选项:

我可以设置从 jar 文件运行的 Java 最大堆大小吗?

也就是说,如果您控制该过程,则可以使用 java.security.Policy.setPolicy 自己管理策略对象。

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.

夜声 2024-09-09 06:27:33

您可以在此处查看如何使用策略文件。如果您使用 netbeans 或其他一些 IDE,您应该能够添加

-Djava.security.policy=myPolicyFile

作为虚拟机的一个选项,通常可以在项目属性中的某个位置找到。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文