简体   繁体   English

具有jvm args的可运行jar

[英]Runnable jar with jvm args

I was trying to create a runnable jar file using Eclipse. 我试图使用Eclipse创建可运行的jar文件。
The problem is that the vm parameters I have added to the run configuration in the Eclipse were not saved in any way. 问题是我以任何方式都没有保存我在Eclipse中添加到运行配置中的vm参数。

I know I can create a batch file that will run the jar with the needed arguments, but I would prefer my users will just run the jar itself. 我知道我可以创建一个批处理文件,该批处理文件将使用所需的参数运行jar,但是我希望用户只运行jar本身。

My question is therefore, is there any way to pass vm arguments to the runnable jar not by command line? 因此,我的问题是,有没有办法通过命令行将vm参数传递给可运行的jar?

Briefly, you can't do this without some form of wrapper. 简而言之,如果没有某种形式的包装,您将无法做到这一点。 You can write a .bat file and/or a .sh script to invoke the JVM with appropriate settings. 您可以编写.bat文件和/或.sh脚本以使用适当的设置来调用JVM。

You may also want to check out JavaServiceWrapper , which provides a means to wrap a .jar with executable params and let it run as a standalone or service (despite its name). 您可能还想看看JavaServiceWrapper ,它提供了一种将.jar与可执行参数打包的方法,并使其作为独立程序服务(尽管其名称)运行。 It has a set of features to allow you to control the JVM execution in a variety of fashions. 它具有一组功能,可让您以各种方式控制JVM的执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM