Centos7安装jdk1.8

Centos7安装jdk1.8(两种安装方式)

1,检查本机是否安装了jdk,安装了就不用安装了
命令如下:

[root@localhost ~]# java -version
-bash: java: 未找到命令
[root@localhost ~]# 
注意:说明未安装

一,下载安装

JDK下载地址:
http://www.oracle.com/technetwork/java/javase/downloads/index.html
下载你自己需要的版本

3,使用rz命令上传,没有的可以下载:yum install lrzsz
3.1上传到 /home 目录下

[root@localhost ~]# yum install lrzsz     --安装rz命令  
[root@localhost ~]# cd /home              --进入/home目录   
[root@localhost home]#rz                  --上传
[root@localhost home]# tar -zxvf jdk-8u181-linux-x64.tar.gz  --解压

如果觉得名字太长可以重新命名

[root@localhost home]# mv jdk1.8.0_181/ jdk1.8 
[root@localhost home]#mkdir /usr/java          --创建/java目录 
[root@localhost home]# mv jdk1.8 /usr/java     --转移到/usr/java目录下 

配置环境变量

vim命令不能使用??只能使用vi命令?
安装一下吧
[root@localhost home]#yum install vim
[root@localhost home]# vim /etc/profile

在export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL 之后新增以下三行

export JAVA_HOME=/usr/java/jdk1.8
export CLASSPATH=.:%JAVA_HOME%/lib/dt.jar:%JAVA_HOME%/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin

使刚刚的配置文件生效

[root@localhost home]# source /etc/profile

测试jdk是否安装成功

[root@localhost home]# java -version
java version "1.8.0_191"
Java(TM) SE Runtime Environment (build 1.8.0_191-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.191-b12, mixed mode)

“出现以上说明成功”

二,命令安装

1,通过以下命令获得java JDK列表

[root@localhost huimou]# yum -y list java*
CentOS Linux 7 - AppStream                                                                                             1.1 MB/s | 8.8 MB     00:07    
CentOS Linux 7 - BaseOS                                                                                                371 kB/s | 5.6 MB     00:15    
CentOS Linux 7 - Extras                                                                                                6.1 kB/s |  10 kB     00:01    
可安装的软件包
java-1.8.0-openjdk.x86_64                                                   1:1.8.0.302.b08-0.el8_4                                           appstream
java-1.8.0-openjdk-accessibility.x86_64                                     1:1.8.0.302.b08-0.el8_4                                           appstream
java-1.8.0-openjdk-demo.x86_64                                              1:1.8.0.302.b08-0.el8_4                                           appstream
java-1.8.0-openjdk-devel.x86_64                                             1:1.8.0.302.b08-0.el8_4                                           appstream
java-1.8.0-openjdk-headless.x86_64                                          1:1.8.0.302.b08-0.el8_4                                           appstream
java-1.8.0-openjdk-headless-slowdebug.x86_64                                1:1.8.0.302.b08-0.el8_4                                           appstream
java-1.8.0-openjdk-javadoc.noarch                                           1:1.8.0.302.b08-0.el8_4                                           appstream
java-1.8.0-openjdk-javadoc-zip.noarch                                       1:1.8.0.302.b08-0.el8_4                                           appstream
java-1.8.0-openjdk-slowdebug.x86_64                                         1:1.8.0.302.b08-0.el8_4                                           appstream
java-1.8.0-openjdk-src.x86_64                                               1:1.8.0.302.b08-0.el8_4                                           appstream
java-11-openjdk.x86_64                                                      1:11.0.12.0.7-0.el8_4                                             appstream
java-11-openjdk-demo.x86_64                                                 1:11.0.12.0.7-0.el8_4                                             appstream
java-11-openjdk-devel.x86_64                                                1:11.0.12.0.7-0.el8_4                                             appstream
java-11-openjdk-headless.x86_64                                             1:11.0.12.0.7-0.el8_4                                             appstream
java-11-openjdk-javadoc.x86_64                                              1:11.0.12.0.7-0.el8_4                                             appstream
java-11-openjdk-javadoc-zip.x86_64                                          1:11.0.12.0.7-0.el8_4                                             appstream
java-11-openjdk-jmods.x86_64                                                1:11.0.12.0.7-0.el8_4                                             appstream
java-11-openjdk-src.x86_64                                                  1:11.0.12.0.7-0.el8_4                                             appstream
java-11-openjdk-static-libs.x86_64                                          1:11.0.12.0.7-0.el8_4                                             appstream
java-atk-wrapper.x86_64                                                     0.33.2-6.el8                                                      appstream
javapackages-filesystem.noarch                                              5.3.0-1.module_el8.0.0+11+5b8c10bd                                appstream
javapackages-tools.noarch                                                   5.3.0-1.module_el8.0.0+11+5b8c10bd                                appstream
[root@localhost huimou]#

2,通过yum安装JDK下载 java-1.8.0 可以选择自己需要的版本!!!

yum -y install java-1.8.0-openjdk*

3,等待安装完成

通过yum默认安装的路径为/usr/lib/jvm/java-版本号(如/usr/lib/jvm/java-1.8.0)

4,测试jdk是否安装成功

[root@localhost huimou]# java -version
openjdk version "1.8.0_302"
OpenJDK Runtime Environment (build 1.8.0_302-b08)
OpenJDK 64-Bit Server VM (build 25.302-b08, mixed mode)

你可能感兴趣的:(Linux,centos,jdk1.8,linux,jdk,centos)