JDK安装

  • A+
所属分类:Linux

一. Oracle JDK

1.官方下载(因官方许可证更新,下载需验证账户)

wget https://github.com/frekele/oracle-java/releases/download/8u201-b09/jdk-8u201-linux-x64.rpm

历史下载
https://github.com/frekele/oracle-java/releases/tag/8u201-b09

2.编写脚本

tee  jdk.sh <<-'EOF'
#!/bin/sh
rpm -ivh jdk-8u201-linux-x64.rpm;
echo "export JAVA_HOME=/usr/java/jdk1.8.0_201-amd64" >> /etc/profile
echo "export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar" >> /etc/profile
echo "export PATH=$PATH:$JAVA_HOME/bin" >> /etc/profile
source /etc/profile
update-alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_201-amd64/bin/java 100
update-alternatives --config java
EOF

3.执行脚本

echo 2 | sh jdk.sh

4.测试是否安装成功

java -version

二.OpenJDK

1.查看yum中都有哪些版本

yum list | grep openjdk

2.安装openjdk 1.8

yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel

3.测试

java -version

avatar

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: