linux系统安装jdk
Posted zhuzhaoli
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了linux系统安装jdk相关的知识,希望对你有一定的参考价值。
一、yum安装
1、查看可安装的jdk版本
[root@centos76 ~]# yum -y list java* Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * elrepo: mirrors.neusoft.edu.cn * epel: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Installed Packages ...
2、选择对应版本进行安装
[root@centos76 ~]# yum install -y java-1.8.0-openjdk* Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile epel/x86_64/metalink | 6.5 kB 00:00:00 * base: mirrors.aliyun.com * elrepo: mirrors.neusoft.edu.cn * epel: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com ...
三、查看安装的JDK版本
[root@centos76 ~]# java -version openjdk version "1.8.0_222" OpenJDK Runtime Environment (build 1.8.0_222-b10) OpenJDK 64-Bit Server VM (build 25.222-b10, mixed mode)
自动安装jdk的路径是在/usr/lib/jvm。
四、查看已经安装的jdk
[root@centos76 jvm]# rpm -qa| grep jdk copy-jdk-configs-3.3-10.el7_5.noarch java-1.8.0-openjdk-javadoc-1.8.0.222.b10-1.el7_7.noarch java-1.8.0-openjdk-1.8.0.222.b10-1.el7_7.x86_64 java-1.8.0-openjdk-accessibility-debug-1.8.0.222.b10-1.el7_7.x86_64 java-1.8.0-openjdk-devel-debug-1.8.0.222.b10-1.el7_7.x86_64 java-1.8.0-openjdk-debug-1.8.0.222.b10-1.el7_7.x86_64 java-1.8.0-openjdk-src-1.8.0.222.b10-1.el7_7.x86_64 java-1.8.0-openjdk-accessibility-1.8.0.222.b10-1.el7_7.x86_64 java-1.8.0-openjdk-javadoc-zip-1.8.0.222.b10-1.el7_7.noarch java-1.8.0-openjdk-headless-1.8.0.222.b10-1.el7_7.x86_64 java-1.8.0-openjdk-demo-1.8.0.222.b10-1.el7_7.x86_64 java-1.8.0-openjdk-src-debug-1.8.0.222.b10-1.el7_7.x86_64 java-1.8.0-openjdk-demo-debug-1.8.0.222.b10-1.el7_7.x86_64 java-1.8.0-openjdk-devel-1.8.0.222.b10-1.el7_7.x86_64 java-1.8.0-openjdk-javadoc-debug-1.8.0.222.b10-1.el7_7.noarch java-1.8.0-openjdk-headless-debug-1.8.0.222.b10-1.el7_7.x86_64 java-1.8.0-openjdk-javadoc-zip-debug-1.8.0.222.b10-1.el7_7.noarch
五、卸载JDK
[root@centos76 jvm]# yum -y remove java-1.8.0-openjdk-headless-1.8.0.222.b10-1.el7_7.x86_64
二、jdk压缩包安装
1、下载安装包
在https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html中选择合适的版本进行下载,然后上传到linux的/usr/local/java文件夹下。
2、解压压缩包
使用如下命令解压压缩包:
tar zxvf jdk-8u66-linux-x64.tar.gz
删除压缩包:
rm -rf jdk-8u66-linux-x64.tar.gz
3、设置jdk环境变量
修改/etc/profile,添加如下内容:
JAVA_HOME=/usr/local/java/jdk1.8.0_221 PATH=$JAVA_HOME/bin:$PATH export PATH JAVA_HOME
4、生效环境变量
source /etc/profile
5、查看jdk
java -version
以上是关于linux系统安装jdk的主要内容,如果未能解决你的问题,请参考以下文章