安装方法
方法一:手动解压JDK
方法二:yum安装JDK
方法三:用rpm安装JDK
jdk8 下载位置
https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
方法一:手动解压JDK的压缩包,设置环境变量
1.创建java目录
[root@centos001 ~]# mkdir /usr/java
[root@centos001 ~]# cd /usr/java/
2.下载,然后解压,这一步我已经将软件下载并放到/sofwaretar 目录下
拷贝到/usr/java
[root@centos001 java]# cp /softwaretar/jdk-8u221-linux-x64.tar.gz ./
[root@centos001 java]# ll
total 177192
-rw-r--r--. 1 root root 181442359 Dec 23 14:04 jdk-8u221-linux-x64.tar.gz
[root@centos001 java]# tar -zxvf jdk-8u221-linux-x64.tar.gz
方法二:yum安装JDK
1.查看yum库中有那些jdk版本
[root@centos001 java]# yum search java|grep jdk
ldapjdk-javadoc.x86_64 : Javadoc for ldapjdk
java-1.6.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.6.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.6.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.6.0-openjdk-javadoc.x86_64 : OpenJDK API Documentation
java-1.6.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.7.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.7.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.7.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.7.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.7.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-debug.x86_64 : OpenJDK Runtime Environment with full debug on
java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos
java-1.8.0-openjdk-demo-debug.x86_64 : OpenJDK Demos with full debug on
java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment
java-1.8.0-openjdk-devel-debug.x86_64 : OpenJDK Development Environment with
java-1.8.0-openjdk-headless.x86_64 : OpenJDK Runtime Environment
java-1.8.0-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full
java-1.8.0-openjdk-javadoc.noarch : OpenJDK API Documentation
java-1.8.0-openjdk-javadoc-debug.noarch : OpenJDK API Documentation for packages
java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle
java-1.8.0-openjdk-src-debug.x86_64 : OpenJDK Source Bundle for packages with
ldapjdk.x86_64 : The Mozilla LDAP Java SDK
2.选择版本,进行安装
[root@centos001 java]# yum install java-1.8.0-openjdk
方法三:用rpm安装JDK
1. 下载
已下载软件到/usr/java 目录下
2.使用rpm命令安装
rpm -ivh jdk-8u221-linux-x64.rpm
<<设置环境变量>>
1.设置环境变量
[root@centos001 java]# vi /etc/profile
添加如下内容:
#set java environment
JAVA_HOME=/usr/java/jdk1.8.0_221
JRE_HOME=/usr/java/jdk1.8.0_221/JRE
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
生效修改
[root@centos001 java]#source /etc/profile
2.验证
[root@centos001 java]# java -version
java version "1.8.0_221"
Java(TM) SE Runtime Environment (build 1.8.0_221-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.221-b11, mixed mode)