<tfoot id='EPgEB'></tfoot>

    <legend id='EPgEB'><style id='EPgEB'><dir id='EPgEB'><q id='EPgEB'></q></dir></style></legend>

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

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

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

      TOMCAT_OPTS、环境变量和 System.getEnv()

      TOMCAT_OPTS, environment variable and System.getEnv()(TOMCAT_OPTS、环境变量和 System.getEnv())
      • <i id='AR6rn'><tr id='AR6rn'><dt id='AR6rn'><q id='AR6rn'><span id='AR6rn'><b id='AR6rn'><form id='AR6rn'><ins id='AR6rn'></ins><ul id='AR6rn'></ul><sub id='AR6rn'></sub></form><legend id='AR6rn'></legend><bdo id='AR6rn'><pre id='AR6rn'><center id='AR6rn'></center></pre></bdo></b><th id='AR6rn'></th></span></q></dt></tr></i><div id='AR6rn'><tfoot id='AR6rn'></tfoot><dl id='AR6rn'><fieldset id='AR6rn'></fieldset></dl></div>
        <tfoot id='AR6rn'></tfoot>

        1. <small id='AR6rn'></small><noframes id='AR6rn'>

          1. <legend id='AR6rn'><style id='AR6rn'><dir id='AR6rn'><q id='AR6rn'></q></dir></style></legend>

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

                  <tbody id='AR6rn'></tbody>
                本文介绍了TOMCAT_OPTS、环境变量和 System.getEnv()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我使用tomcat,我想在我的java代码中获取一个环境变量.

                I use tomcat and I want to get an environment variable in my java code.

                要设置环境变量,我使用这个 bash 命令:

                To set an environment variable, I use this bash command :

                export TOMCAT_OPTS=-Dmy.var=foo
                

                之后我启动tomcat

                After it I start tomcat

                ./startup.sh (in bin folder of tomcat)
                

                在我的 java 代码中,我尝试获取这个变量:

                In my java code, I try to get this variable :

                System.getEnv("my.var")
                

                但它返回 NULL.

                我该怎么做?

                我准确地说,如果我使用 maven 启动 tomcat 并使用 eclipse 环境选项卡,则找到变量!但是我需要像上面那样在生产模式下启动tomcat.

                I precise that if I use maven to launch tomcat and use eclipse environment tab, the variable is found ! But I need to launch tomcat like above in production mode.

                直接使用 export MY_VAR 时,它在本地运行,但不在我的服务器上...

                when using export MY_VAR directly it runs in local but not on my server...

                推荐答案

                终于在CATALINA_HOME中找到了一个名为tomcat6.conf的配置文件.我将 export my.var=foo 添加到文件末尾, System.getenv("my.var") 现在返回值...

                I finally found a config file named tomcat6.conf in CATALINA_HOME. I add export my.var=foo to the end of file and System.getenv("my.var") now returns the value...

                噩梦……

                这篇关于TOMCAT_OPTS、环境变量和 System.getEnv()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                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 中的默认语言环境设置以使其保持一致?)
                    <tbody id='GTu2h'></tbody>
                  <legend id='GTu2h'><style id='GTu2h'><dir id='GTu2h'><q id='GTu2h'></q></dir></style></legend>
                      <bdo id='GTu2h'></bdo><ul id='GTu2h'></ul>

                        • <tfoot id='GTu2h'></tfoot>

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

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