安装openjdk
官方地址http://openjdk.java.net/,jre是java的运行环境 ,如果需要java程序需要安装jdk
Debian, Ubuntu, 安装jre
sudo apt-get install openjdk-8-jre #8的版本
sudo apt-get install openjdk-7-jre #7的版本
Fedora, Oracle Linux, Red Hat Enterprise Linux,的安装方式
$ su -c "yum install java-11-openjdk"
$ su -c "yum install java-1.8.0-openjdk"
$ su -c "yum install java-1.7.0-openjdk"
jdk的安装
Debian, Ubuntu, 安装jdk
sudo apt-get install openjdk-8-jdk #8的版本
sudo apt-get install openjdk-7-jdk #7的版本
Fedora, Oracle Linux, Red Hat Enterprise Linux,的安装方式
$ su -c "yum install java-1.8.0-openjdk-devel"
$ su -c "yum install java-1.7.0-openjdk-devel"
安装Oracle Java SE
卸载openjdk 通过rpm -qa | grep java 命令查找openjdk
rpm -qa | grep java
python-javapackages-3.4.1-11.el7.noarch
tzdata-java-2018e-3.el7.noarch
javapackages-tools-3.4.1-11.el7.noarch
java-1.8.0-openjdk-headless-1.8.0.181-3.b13.el7_5.x86_64
java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64
通过rpm -e --nodeps (安装包名称) 命令依次卸载
rpm -e --nodeps python-javapackages-3.4.1-11.el7.noarch
rpm -e --nodeps tzdata-java-2018e-3.el7.noarch
rpm -e --nodeps javapackages-tools-3.4.1-11.el7.noarch
rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.181-3.b13.el7_5.x86_64
rpm -e --nodeps java-1.8.0-openjdk-1.8.0.181-3.b13.el7_5.x86_64
删完之后可以再通过 rpm -qa | grep Java 命令来查询出是否删除掉
java官方服务器下载地址http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
由于必须接受Accept License Agreement才能下载,所有需要在wget增加cookie
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u181-b13/96a7b8442fe848ef90c96a2fad6ed6d1/jdk-8u181-linux-x64.rpm"
安装rpm的命令 rpm -ivh
rpm -ivh jdk-8u181-linux-x64.rpm
warning: jdk-8u181-linux-x64.rpm: Header V3 RSA/SHA256 Signature, key ID ec551f03: NOKEY
Preparing... ################################# [100%]
Updating / installing...
1:jdk1.8-2000:1.8.0_181-fcs ################################# [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
验证安装结果
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)
网友评论