查看Linux中自帶的jdk ,設置JAVA_HOME


在配置hadoop是,進行格式化hadoop的時候,出現找不到jdk

 

我用centos7是64位的, 發現本機有java ,就找了一下其位置

找到了jdk-1.7.0_75

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.7.0-openjdk.x86_64/bin/java         (能夠看出文件是link ,是個連接)
[root@host2 hadoop-1.1.2]# ls -l /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java-rwxr-xr-x. 1 root root 36548 Oct 25 2011 /usr/lib/jvm/jre-1.7.0-openjdk.x86_64/bin/java
[root@host2 hadoop-1.1.2]# cd /usr/lib/jvm/jre-1.7.0-openjdk.x86_64
[root@host2 jre-1.7.0-openjdk.x86_64]# ls
bin lib

 

如此來,能夠暫時的判定是  /usr/lib/jvm/jre-1.7.0-openjdk.x86_64

root用戶下改配置文件 : vi  /etc/profile

找到export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

在下面寫上:

export JAVA_HOME=/usr/lib/jvm/jre-1.7.0-openjdk.x86_64
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar

 

:wq  保存退出

用echo $JAVA_HOME

#更新jdk


update-alternatives --install /usr/bin/java java /opt/jdk1.7.0_79/bin/java 300 
update-alternatives --install /usr/bin/javac javac /opt/jdk1.7.0_79/bin/javac 300 
update-alternatives --install /usr/bin/jar jar /opt/jdk1.7.0_79/bin/jar 300

update-alternatives --config java
選擇帶有jdk1.7.0_79 的選項

便可以了
相關文章
相關標籤/搜索