将整个文件传递给JVM参数 [英] Passing an entire file to JVM arguments

查看:138
本文介绍了将整个文件传递给JVM参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个系统都需要将相同的属性加载到JVM。我可以使用-D标志一次加载一个属性,但我正在寻找能够一次加载整个文件中的所有属性的东西。例如:

I have several systems that all need to load the same properties to the JVM. I can use the -D flag to load one property at a time, but i am looking for something that will load all the properties in an entire file at one time. For instance:

我可以将--options-file = blah.properties添加到我网络上的所有jvms,一次,然后从此只更改属性文件,这可能是网络共享上的单个中心文件。

I could just add --options-file=blah.properties to all jvms on my network, once, and from then on only change the properties file, which could be a single central file over a network share.

谢谢,

编辑:任何参数或命令也必须在Windows环境中工作。因此,任何特定于unix的bash或脚本黑客都行不通。

Any arguments or commands must also work in a windows environment. Therefore any bash or scripting hacks specific to unix will not work.

推荐答案

这大致就是我们这样做的方式:

That's roughly how we do it:

java $(tr'\ n'''< options_file)其他args ...

这里 options_file 包含就绪 -Dsomething -Xsomething 值,每行一个。 tr 命令只是用空格替换每个换行符。

Here options_file contains ready -Dsomething or -Xsomething values, one per line. The tr command just replaces every newline with a space.

这篇关于将整个文件传递给JVM参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆