使用 Java Web Start/JNLP 启用 JVM 选项

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3494787/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-30 02:05:46  来源:igfitidea点击:

Enabling JVM options with Java Web Start / JNLP

javajvmjava-web-startjnlp

提问by mikera

I'm creating a Web Start application which would benefit from some of the newer JVM options (especially escape analysis, G1 garbage collector etc.)

我正在创建一个 Web Start 应用程序,它将受益于一些较新的 JVM 选项(尤其是逃逸分析、G1 垃圾收集器等)

At the same time, I would like the application to work gracefully on older JVMs that do not support these options.

同时,我希望应用程序能够在不支持这些选项的旧 JVM 上正常运行。

Is there a good way of achieving this?

有没有好的方法来实现这一目标?

回答by David J. Liszewski

As Thorbj?rnmentioned, Java 6 u10 allows multiple j2seelements in JNLP. The JNLP File Syntaxresourcessection of the latest Java Web Start Developer's Guide, indicates that multiple j2seelements, each with java-vm-argsattributes can be specified with the most preferred occurring first. For example:

正如Thorbj?rn 所提到的,Java 6 u10 允许j2se在 JNLP 中使用多个元素。最新的Java Web Start Developer's GuideJNLP 文件语法resources部分指出可以指定多个元素,每个元素都具有属性,最喜欢的首先出现。例如:j2sejava-vm-args

<j2se version="1.3" initial-heap-size="64m" max-heap-size="128m"/>
<j2se version="1.4.2+" href="http://java.sun.com/products/autodl/j2se" 
      java-vm-args="-esa -Xnoclassgc"/>