配置环境变量
在/etc/profile下增加
# set Java environment
export JAVA_HOME=/usr/share/jdk1.6.0_43
export PATH=$JAVA_HOME/bin:$PATH
export JRE_HOME="$JAVA_HOME/jre"
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
修改完成后,使用source /etc/profile 命令进行更新
测试
[root@localhost ~]# echo $JAVA_HOME
/usr/share/jdk1.6.0_43
[root@localhost ~]# echo $PATH
/usr/share/jdk1.6.0_43/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@localhost ~]# echo $CLASSPATH
.:/usr/share/jdk1.6.0_43/lib/dt.jar:/usr/share/jdk1.6.0_43/lib/tools.jar