英文:
How to configure java app externally when some of the arguments configure with java command
问题
我有一个Java应用程序,是通过以下命令运行的:
java -Xmx2g -jar app.jar
我无法修改java
命令的执行方式。有没有办法向JVM添加额外的标志?我尝试过添加JAVA_OPTS
环境变量,但没有效果。例如:
export JAVA_OPTS=-XX:+PrintFlagsFinal
java -Xmx2g -jar app.jar
不会打印标志。
英文:
I have a java app, that is run with command:
java -Xmx2g -jar app.jar
I cannot modify the way that java
command is executed. Is there a way to add additional flags to the JVM? I tried to add JAVA_OPTS
environment variable but it doesn't help. For example:
export JAVA_OPTS=-XX:+PrintFlagsFinal
java -Xmx2g -jar app.jar
Doesn't print flags.
答案1
得分: 1
尝试使用 _JAVA_OPTIONS
,这是一个可能已被移除的未记录特性,但如果可能的话,就是这样操作。
否则,也许正在运行的 java 命令就是像那样编写的,这意味着它在你的 shell $PATH 变量中查找,这意味着你可以更改它,使其运行一个调用实际 java 的脚本,同时添加一些选项。
英文:
Try _JAVA_OPTIONS
, which is an undocumented feature that probably has been removed now, but, if this is possible at all, that's how to do it.
Otherwise, perhaps the java command being run is written just like that, which means it is looked up in your shell $PATH variable, which means you can change that, and make that run a script which invokes the actual java, whilst adding a couple of options.
答案2
得分: 0
export JAVA_TOOL_OPTIONS="-XX:+PrintFlagsFinal";
/test/jre/bin/java -cp . DiskSizeCalculation17;
Picked up JAVA_TOOL_OPTIONS: -XX:+PrintFlagsFinal;
[Global flags]
intx ActiveProcessorCount = -1 {product}
uintx AdaptiveSizeDecrementScaleFactor = 4 {product}
uintx AdaptiveSizeMajorGCDecayTimeScale = 10 {product}
uintx AdaptiveSizePausePolicy = 0 {product}
uintx AdaptiveSizePolicyCollectionCostMargin = 50 {product}
uintx AdaptiveSizePolicyInitializingSteps = 20 {product}
uintx AdaptiveSizePolicyOutputInterval = 0 {product}
英文:
You may try JAVA_TOOL_OPTIONS
export JAVA_TOOL_OPTIONS="-XX:+PrintFlagsFinal"
/test/jre/bin/java -cp . DiskSizeCalculation17
Picked up JAVA_TOOL_OPTIONS: -XX:+PrintFlagsFinal
[Global flags]
intx ActiveProcessorCount = -1 {product}
uintx AdaptiveSizeDecrementScaleFactor = 4 {product}
uintx AdaptiveSizeMajorGCDecayTimeScale = 10 {product}
uintx AdaptiveSizePausePolicy = 0 {product}
uintx AdaptiveSizePolicyCollectionCostMargin = 50 {product}
uintx AdaptiveSizePolicyInitializingSteps = 20 {product}
uintx AdaptiveSizePolicyOutputInterval = 0 {product}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论