参考原文:http://www.cnblogs.com/plinx/archive/2013/06/01/3113106.html
1,配置默认JDK版本:标红部分是jdk路径。
sudo update-alternatives --install /usr/bin/java java /home/wangpan/jdk1.8.0_121/bin/java 300
sudo update-alternatives --install /usr/bin/javac javac /home/wangpan/jdk1.8.0_121/bin/javac 300
sudo update-alternatives --install /usr/bin/jar jar /home/wangpan/jdk1.8.0_121/bin/jar 300
sudo update-alternatives --install /usr/bin/javah javah /home/wangpan/jdk1.8.0_121/bin/javah 300
sudo update-alternatives --install /usr/bin/javap javap /home/wangpan/jdk1.8.0_121/bin/javap 300
2,更改默认jdk:
sudo update-alternatives --config java
3,执行java -version