linux中查看环境变量有两种方法:

第一种是看系统环境变量的配置文件:

/etc/profile这个是环境变量配置文件,里面是应经配置号的环境变量。当你在Ubuntu上安装配置jdk的JAVA_HOME时,需要把路径配置在里面。

例如:

在bash下输入gedit /etc/profile

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))

# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).

if [ "$PS1" ]; then

if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then

# The file bash.bashrc already sets the default PS1.

# PS1='\h:\w\$ '

if [ -f /etc/bash.bashrc ]; then

. /etc/bash.bashrc

fi

else

if [ "`id -u`" -eq 0 ]; then

PS1='# '

else

PS1='$ '

fi

fi

fi

# The default umask is now handled by pam_umask.

# See pam_umask(8) and /etc/login.defs.

if [ -d /etc/profile.d ]; then

for i in /etc/profile.d/*.sh; do

if [ -r $i ]; then

. $i

fi

done

unset i

fi

#set Java Environment

export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_67

export CLASSPATH=".:$JAVA_HOME/lib:$CLASSPATH"

export PATH="$JAVA_HOME/:$PATH"

如果没有找到环境变量,那就是环境变量没有配好。

第二种方法使用命令:

还可以用env命令,这个是查看当前系统的环境变量的。

要分页的话就加通道 env |more。

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐