jdk升级

1、首先到oracle官网下载所需jdk,这里是jdk1.8.0-181版本

http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.tar.gz

2、上传到服务器

3、解压到安装目录

tar xvf jdk-8u181-linux-x64.tar.gz -C /user/lib/jvm/
ls /usr/lib/jvm/
java-8-oracle  jdk1.8.0_181

4、升级指令

# 使用新java
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.8.0_181/bin/java 300
# 使用新javac
update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk1.8.0_181/bin/javac 300
# 使用新jar
update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk1.8.0_181/bin/jar 300

5、切换新jdk

# 选择2
update-alternatives --config java
There are 2 choices for the alternative java (providing /usr/bin/java).

  Selection    Path                                     Priority   Status
------------------------------------------------------------
  0            /usr/lib/jvm/java-8-oracle/jre/bin/java   1081      auto mode
* 1            /usr/lib/jvm/java-8-oracle/jre/bin/java   1081      manual mode
  2            /usr/lib/jvm/jdk1.8.0_181/bin/java        300       manual mode

6、验证

java -version
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)

你可能感兴趣的:(jdk升级)