gpt4 book ai didi

java - 为什么Java代码不显示环境变量$JAVA_HOME和$M2_HOME?

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:08:54 41 4
gpt4 key购买 nike

<分区>

在 .bashrc 文件末尾插入环境变量:

$JAVA_HOME

JAVA_HOME="/usr/lib/jvm/java-8-oracle/​"
CLASSPATH="JAVA_HOME/lib/:$CLASSPATH"
PATH="$JAVA_HOME/bin/:$PATH"

$M2_HOME

M2_HOME="/usr/share/maven/"
M2="$M2_HOME/bin"
PATH="$M2:$PATH" PATH=$M2:$PATH

当我运行代码片段时:

Map<String, String> env = System.getenv();
for (String envName : env.keySet()) {
System.out.format("%s=%s%n", envName, env.get(envName));
}

显示我所有的环境变量:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games" 
XAUTHORITY=/home/ricardoramos/.Xauthority
XMODIFIERS=@im=ibus
XDG_DATA_DIRS=/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/
GDMSESSION=ubuntu
MANDATORY_PATH=/usr/share/gconf/ubuntu.mandatory.path
TEXTDOMAINDIR=/usr/share/locale/
GTK_IM_MODULE=ibus
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-rS3vXA2fJM
DEFAULTS_PATH=/usr/share/gconf/ubuntu.default.path
XDG_CURRENT_DESKTOP=Unity
SWT_GTK3=0
UPSTART_SESSION=unix:abstract=/com/ubuntu/upstart-session/1000/1996...

为什么 Java 代码不显示环境变量 $JAVA_HOME$M2_HOME

41 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com