1.下载安装jdk8 tar.gz的包或者其他服务器的jdk8的包拷贝过来
2.将准备好的jdk8复制到/usr/local/
# mv jdk1.8.0_92 /usr/local/
3.添加路径到/etc/profile,保存
# vim /etc/profile
export JAVA_HOME=/usr/local/jdk1.8.0_92
export JAVA_BIN=/usr/local/jdk1.8.0_92/bin
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
#source /etc/profile
4.执行以后发现还是java7的版本,那么需要把jdk8设置成默认的版本
# update-alternatives --install /usr/bin/java java /usr/local/jdk1.8.0_92/bin/java 300
# update-alternatives --install /usr/bin/javac javac /usr/local/jdk1.8.0_92/bin/javac 300
# update-alternatives --config java
5.再查询java的版本