java 获取环境变量
In Java, how to get the value (string) of an environment variable?
在Java中 ,如何获取环境变量的值( 字符串 )?
You may call the System.getenv(name)
library function in Java to get the environment variable value.
您可以使用Java调用System .getenv(name)
库函数来获取环境变量值。
public static String getenv(String name)
Parameters:
name – the name of the environment variable参数:
name –环境变量的名称Returns:
the string value of the variable, or null if the variable is not defined in the system environment返回值:
变量的字符串值;如果在系统环境中未定义变量,则为null
One example, in the Java REPL:
Java REPL中的一个示例:
java> System.getenv("JAVA_HOME")
java.lang.String res0 = "/usr/java/default/"
Answered by dtivl.
dtivl回答。
翻译自: https://www.systutorials.com/how-to-get-an-environment-variable-in-java/
java 获取环境变量