<small id='lEQXX'></small><noframes id='lEQXX'>

    <bdo id='lEQXX'></bdo><ul id='lEQXX'></ul>

  • <legend id='lEQXX'><style id='lEQXX'><dir id='lEQXX'><q id='lEQXX'></q></dir></style></legend>

      <i id='lEQXX'><tr id='lEQXX'><dt id='lEQXX'><q id='lEQXX'><span id='lEQXX'><b id='lEQXX'><form id='lEQXX'><ins id='lEQXX'></ins><ul id='lEQXX'></ul><sub id='lEQXX'></sub></form><legend id='lEQXX'></legend><bdo id='lEQXX'><pre id='lEQXX'><center id='lEQXX'></center></pre></bdo></b><th id='lEQXX'></th></span></q></dt></tr></i><div id='lEQXX'><tfoot id='lEQXX'></tfoot><dl id='lEQXX'><fieldset id='lEQXX'></fieldset></dl></div>
        <tfoot id='lEQXX'></tfoot>
      1. 使用 Java 11 时 JDK_JAVA_OPTIONS 和 JAVA_TOOL_OPTIONS 有什么区别?

        What is the difference between JDK_JAVA_OPTIONS and JAVA_TOOL_OPTIONS when using Java 11?(使用 Java 11 时 JDK_JAVA_OPTIONS 和 JAVA_TOOL_OPTIONS 有什么区别?)
          <bdo id='Tzq2x'></bdo><ul id='Tzq2x'></ul>

        • <small id='Tzq2x'></small><noframes id='Tzq2x'>

                <tbody id='Tzq2x'></tbody>
              <i id='Tzq2x'><tr id='Tzq2x'><dt id='Tzq2x'><q id='Tzq2x'><span id='Tzq2x'><b id='Tzq2x'><form id='Tzq2x'><ins id='Tzq2x'></ins><ul id='Tzq2x'></ul><sub id='Tzq2x'></sub></form><legend id='Tzq2x'></legend><bdo id='Tzq2x'><pre id='Tzq2x'><center id='Tzq2x'></center></pre></bdo></b><th id='Tzq2x'></th></span></q></dt></tr></i><div id='Tzq2x'><tfoot id='Tzq2x'></tfoot><dl id='Tzq2x'><fieldset id='Tzq2x'></fieldset></dl></div>

              • <tfoot id='Tzq2x'></tfoot>
              • <legend id='Tzq2x'><style id='Tzq2x'><dir id='Tzq2x'><q id='Tzq2x'></q></dir></style></legend>

                  本文介绍了使用 Java 11 时 JDK_JAVA_OPTIONS 和 JAVA_TOOL_OPTIONS 有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  JDK_JAVA_OPTIONS 和 JAVA_TOOL_OPTIONS 使用 Java 11 时?

                  What is the exact difference between JDK_JAVA_OPTIONS and JAVA_TOOL_OPTIONS when using Java 11?

                  我正在使用一个小型测试程序:

                  I'm using a tiny test program:

                  public class Foo {
                    public static final void main(String[] args) {
                      System.out.println("arg: " + System.getProperty("arg"));
                    }
                  }
                  

                  这两个环境变量似乎做的一样,但输出略有不同.这让我相信他们可能有不同的用例:

                  The two environment variables seem to do the same, but the output is slightly different. That makes me believe they might have different use cases:

                  $ JDK_JAVA_OPTIONS="-Darg=jdk" java Foo
                  NOTE: Picked up JDK_JAVA_OPTIONS: -Darg
                  arg: jdk
                  
                  $ JAVA_TOOL_OPTIONS="-Darg=tool" java Foo
                  Picked up JAVA_TOOL_OPTIONS: -Darg
                  arg: tool
                  
                  $ JDK_JAVA_OPTIONS="illegalArg" java Foo
                  NOTE: Picked up JDK_JAVA_OPTIONS: illegalArg
                  Error: Cannot specify main class in environment variable JDK_JAVA_OPTIONS
                  
                  $ JAVA_TOOL_OPTIONS="illegalArg" java Foo
                  Picked up JAVA_TOOL_OPTIONS: illegalArg
                  Unrecognized option: illegalArg
                  Error: Could not create the Java Virtual Machine.
                  Error: A fatal exception has occurred. Program will exit.
                  

                  似乎 JDK_JAVA_OPTIONS 优先于 JAVA_TOOL_OPTIONS:

                  $ JDK_JAVA_OPTIONS="-Darg=jdk" JAVA_TOOL_OPTIONS="-Darg=tool" java Foo
                  NOTE: Picked up JDK_JAVA_OPTIONS: -Darg=jdk
                  Picked up JAVA_TOOL_OPTIONS: -Darg=tool
                  arg: jdk
                  

                  但最终还是命令行获胜:

                  But ultimately the command line wins:

                  $ JDK_JAVA_OPTIONS="-Darg=jdk" JAVA_TOOL_OPTIONS="-Darg=tool" java -Darg=cmd Foo
                  NOTE: Picked up JDK_JAVA_OPTIONS: -Darg=jdk
                  Picked up JAVA_TOOL_OPTIONS: -Darg=tool
                  arg: cmd
                  

                  但是,在构建时,只读取 JAVA_TOOL_OPTIONS:

                  When building, though, only JAVA_TOOL_OPTIONS is read:

                  $ JDK_JAVA_OPTIONS="-Darg=jdk" JAVA_TOOL_OPTIONS="-Darg=tool" javac Foo.java
                  Picked up JAVA_TOOL_OPTIONS: -Darg=tool
                  

                  我目前正在使用 AdoptOpenJDK 11 build 28.

                  I'm currently using AdoptOpenJDK 11 build 28.

                  推荐答案

                  @gjoranv 的回答解释了两个变量之间的功能差异.

                  The functional difference between the two variables is explained by @gjoranv's answer.

                  我认为输出的差异源于以下几点:

                  The differences in the output I think stem from the following:

                  1. 这两个变量似乎在启动过程中的不同点实现.

                  1. The two variables seem to be implemented in different points in the launching process.

                  JDK_JAVA_OPTIONS 文档说:

                  为了减少对 JDK_JAVA_OPTIONS 行为的潜在滥用,环境变量中不允许指定主类(例如 -jar)或导致 java 启动器退出而不执行主类的选项(例如 -h).如果这些选项中的任何一个出现在环境变量中,启动器将中止并显示错误消息.

                  In order to mitigate potential misuse of JDK_JAVA_OPTIONS behavior, options that specify the main class (such as -jar) or cause the java launcher to exit without executing the main class (such as -h) are disallowed in the environment variable. If any of these options appear in the environment variable, the launcher will abort with an error message.

                  这一行:

                   Error: Cannot specify main class in environment variable JDK_JAVA_OPTIONS
                  

                  是警告用户可能尝试通过该变量进行破坏的错误消息.

                  is the error message that warns the user of a potential attempt to do mayhem via that variable.

                  我认为 JDK_JAVA_OPTIONS 优先,部分原因是相同的.

                  I think that JDK_JAVA_OPTIONS takes precedence, in part for the same reason.

                  这篇关于使用 Java 11 时 JDK_JAVA_OPTIONS 和 JAVA_TOOL_OPTIONS 有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                  • <tfoot id='W5Vfx'></tfoot>
                    • <legend id='W5Vfx'><style id='W5Vfx'><dir id='W5Vfx'><q id='W5Vfx'></q></dir></style></legend>
                        <tbody id='W5Vfx'></tbody>
                        <bdo id='W5Vfx'></bdo><ul id='W5Vfx'></ul>

                        <small id='W5Vfx'></small><noframes id='W5Vfx'>

                            <i id='W5Vfx'><tr id='W5Vfx'><dt id='W5Vfx'><q id='W5Vfx'><span id='W5Vfx'><b id='W5Vfx'><form id='W5Vfx'><ins id='W5Vfx'></ins><ul id='W5Vfx'></ul><sub id='W5Vfx'></sub></form><legend id='W5Vfx'></legend><bdo id='W5Vfx'><pre id='W5Vfx'><center id='W5Vfx'></center></pre></bdo></b><th id='W5Vfx'></th></span></q></dt></tr></i><div id='W5Vfx'><tfoot id='W5Vfx'></tfoot><dl id='W5Vfx'><fieldset id='W5Vfx'></fieldset></dl></div>