查看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 的选项

即可以了

 

posted @ 2018-01-17 12:19  ぶ会编程  阅读(35425)  评论(0编辑  收藏  举报