在Centos上安装jdk,在/etc/profile中设置好了JAVA_HOME,source之后依然不生效,java -version命令测试一直提示JDK版本为1.5:
[root@Hadoop-DN-08]# java -version
java version "1.5.0"
gij (GNU libgcj) version 4.4.7 20120313 (Red Hat 4.4.7-18)
Copyright (C) 2007 Free Software Foundation,Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
javac -version提示版本是1.8.
解决办法:
先执行下面的命令:
alternatives --install /usr/bin/java java /opt/javahome/jdk1.8.0_144/bin/java 300
再执行第二个命令:
alternatives --config java
按提示选择新的java。
截图: