which java
[root@host2 hadoop-1.1.2]# which java
/usr/bin/java
[root@host2 hadoop-1.1.2]# ls /usr/bin/java
/usr/bin/java
[root@host2 hadoop-1.1.2]# ls -l /usr/bin/java
lrwxrwxrwx. 1 root root 22 Jun 20 03:00 /usr/bin/java -> /etc/alternatives/java
[root@host2 hadoop-1.1.2]# ls -l /etc/alternatives/java
lrwxrwxrwx. 1 root root 39 Jun 20 03:00 /etc/alternatives/java -> /usr/lib/jvm/jre-1.6.0-openjdk/bin/java (可以看出文件是link ,是个链接)
[root@host2 hadoop-1.1.2]# ls -l /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
-rwxr-xr-x. 1 root root 36548 Oct 25 2011 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
[root@host2 hadoop-1.1.2]# cd /usr/lib/jvm/jre-1.6.0-openjdk
[root@host2 jre-1.6.0-openjdk]# ls
bin lib
如此来,可以暂时的断定是 /usr/lib/jvm/jre-1.6.0-openjdk
root用户下改配置文件 : vi /etc/profile
找到export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
在下面写上:
export JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar
:wq 保存退出
用echo $JAVA_HOME