查看并配置JAVA_HOME

转载自https://blog.csdn.net/weixin_41713592/article/details/79941418

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 @ 2019-03-25 10:43  WeoSuper  阅读(1651)  评论(0编辑  收藏  举报