美文网首页
CentOS7下安装JDK

CentOS7下安装JDK

作者: cristik | 来源:发表于2018-11-20 15:22 被阅读0次

安装OpenJDK

安装OpenJDK8 JDK

sudo yum install java-1.8.0-openjdk-devel

安装OpenJDK8 JRE

sudo yum install java-1.8.0-openjdk

安装OpenJDK7 JDK

sudo yum install java-1.7.0-openjdk-devel

安装OpenJDK7 JRE

sudo yum install java-1.7.0-openjdk

安装Oracle Java

Oracle安装包可以从官网下载.
可以通过curl命令下载需要的Java安装包,如果没有curl可以通过以下命令安装

sudo yum install curl

安装Oracle Java9 JRE

curl -L -b "oraclelicense=a" -O http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jre-9.0.4_linux-x64_bin.rpm
sudo yum localinstall jre-9.0.4_linux-x64_bin.rpm

安装Oracle Java9 JDK

curl -L -b "oraclelicense=a" -O http://download.oracle.com/otn-pub/java/jdk/9.0.4+11/c2514751926b4512b076cc82f959763f/jdk-9.0.4_linux-x64_bin.rpm
sudo yum localinstall jdk-9.0.4_linux-x64_bin.rpm

安装Oracle Java8 JRE

curl -L -b "oraclelicense=a" -O http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jre-8u162-linux-x64.rpm
sudo yum localinstall jre-8u162-linux-x64.rpm

安装Oracle Java8 JDK

curl -L -b "oraclelicense=a" -O http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jdk-8u162-linux-x64.rpm
sudo yum localinstall jdk-8u162-linux-x64.rpm

设置默认版本

检查默认的Java版本

 java -version

如果系统中安装有多个版本的Java可以通过系统工具alternatives切换默认版本

sudo alternatives --config java

卸载Java

sudo yum remove java-1.8.0-openjdk-devel    

相关文章

网友评论

      本文标题:CentOS7下安装JDK

      本文链接:https://www.haomeiwen.com/subject/wukxqqtx.html