2013-04-09 225 views
1

我有以下序列JAVA_OPTS无法识别

 
[email protected]:/mnt$ export JAVA_OPTS=-Dmt.config.from=En 
[email protected]:/mnt$ echo $JAVA_OPTS 
-Dmt.config.from=En 
[email protected]:/mnt$ javac hello.java 
[email protected]:/mnt$ java hello 
mt.config.from=null 
[email protected]:/mnt$ java -Dmt.config.from=En hello 
mt.config.from=En 
[email protected]:/mnt$ 

其中hello.java

 
public class hello { 
public static void main (String[] args) { 
     String property = "mt.config.from"; 
     String value = System.getProperty(property); 
     System.out.println(property + "=" + value); 
    } 
} 

为什么我出口JAVA_OPTS = -Dmt.config.from = EN是没有得到通过打招呼采摘。 java吗?由于

回答

4

我认为你需要引用$JAVA_OPTS运行时,如:

java $JAVA_OPTS hello 

我不认为java发射了JVM时检查环境变量的话,那就是更多的脚本中使用的公约。

+0

是JAVA_OPTS而不是JVM的环境变量?为什么要引用它? – user200340 2013-04-09 13:22:43

+0

对不起,明白了。它只对JVM有影响,不影响程序。谢谢。 – user200340 2013-04-09 13:25:00