博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[hyper-V] centos 7 安装 java
阅读量:4927 次
发布时间:2019-06-11

本文共 4429 字,大约阅读时间需要 14 分钟。

# centos安装 java

[root@bogon ~]# java -versionopenjdk version "1.8.0_102"OpenJDK Runtime Environment (build 1.8.0_102-b14)OpenJDK 64-Bit Server VM (build 25.102-b14, mixed mode)

 

进一步查看JDK信息:

[root@bogon ~]# rpm -qa|grep javajava-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64tzdata-java-2016g-2.el7.noarchjavapackages-tools-3.4.1-11.el7.noarchjava-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64python-javapackages-3.4.1-11.el7.noarch[root@bogon ~]#

 

卸载OpenJDK,执行以下操作:

rpm -e --nodeps java-1.8.0-openjdk-1.8.0.102-4.b14.el7.x86_64rpm -e --nodeps tzdata-java-2016g-2.el7.noarchrpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.102-4.b14.el7.x86_64rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.111-2.6.7.8.el7.x86_64rpm -e --nodeps java-1.7.0-openjdk-1.7.0.111-2.6.7.8.el7.x86_64

 

> 下载jdk
 

wget --no-check-certificate --no-cookie --header "Cookie: oraclelicense=accept-securebackup-cookie;" http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm

 

>因为oracle现在要同意协议才能下载,直接使用wget加链接下载不到,所以要加上前面的那些代码.

## 使用rpm安装下载的包

 

rpm -ivh jdk-8u144-linux-x64.rpm

 输出

[root@bogon ~]# wget --no-check-certificate --no-cookie --header "Cookie: oraclelicense=accept-securebackup-cookie;" http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm--2017-09-05 15:25:45-- http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpmResolving download.oracle.com (download.oracle.com)... 184.50.238.49, 184.50.238.48Connecting to download.oracle.com (download.oracle.com)|184.50.238.49|:80... connected.HTTP request sent, awaiting response... 302 Moved TemporarilyLocation: https://edelivery.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm [following]--2017-09-05 15:25:46-- https://edelivery.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpmResolving edelivery.oracle.com (edelivery.oracle.com)... 184.50.91.58, 2600:1417:e:289::2d3e, 2600:1417:e:282::2d3eConnecting to edelivery.oracle.com (edelivery.oracle.com)|184.50.91.58|:443... connected.HTTP request sent, awaiting response... 302 Moved TemporarilyLocation: http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm?AuthParam=1504596464_3396241443c18f4fee2b51825ffccb26 [following]--2017-09-05 15:25:46-- http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-x64.rpm?AuthParam=1504596464_3396241443c18f4fee2b51825ffccb26Connecting to download.oracle.com (download.oracle.com)|184.50.238.49|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 169971490 (162M) [application/x-redhat-package-manager]Saving to: ‘jdk-8u144-linux-x64.rpm’100%[===================================================================================================>] 169,971,490 1.65MB/s in 1m 40s2017-09-05 15:27:26 (1.63 MB/s) - ‘jdk-8u144-linux-x64.rpm’ saved [169971490/169971490][root@bogon ~]# rpm -ivh jdk-8u144-linux-x64.rpm Preparing... ################################# [100%]Updating / installing...1:jdk1.8.0_144-2000:1.8.0_144-fcs ################################# [100%]Unpacking JAR files...tools.jar...plugin.jar...javaws.jar...deploy.jar...rt.jar...jsse.jar...charsets.jar...localedata.jar...[root@bogon ~]# java -versionjava version "1.8.0_144"Java(TM) SE Runtime Environment (build 1.8.0_144-b01)Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)[root@bogon ~]#

 

# 配置环境变量

lrwxrwxrwx. 1 root root 16 Sep 5 15:28 default -> /usr/java/latestdrwxr-xr-x. 9 root root 268 Sep 5 15:28 jdk1.8.0_144lrwxrwxrwx. 1 root root 22 Sep 5 15:28 latest -> /usr/java/jdk1.8.0_144[root@bogon java]# pwd/usr/java

 

>向 /etc/profile文件末尾追加以下内容

[root@bogon java]# sudo vim /etc/profileJAVA_HOME=/usr/java/latestJRE_HOME=/usr/java/latest/jrePATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/binCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/libexport JAVA_HOME JRE_HOME PATH CLASSPATH[root@bogon java]# source /etc/profile //使修改立即生效[root@bogon java]# echo $PATH //查看PATH值/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/latest/bin:/usr/java/latest/jre/bin[root@bogon java]#

 

转载于:https://www.cnblogs.com/hager/p/7478934.html

你可能感兴趣的文章
Toda 2
查看>>
Symfony 1.4 send mail embed image
查看>>
I/O类型
查看>>
PHP程序缓存之文件缓存处理方式
查看>>
PAT 1011-1020 题解
查看>>
201621123034 《Java程序设计》第4周学习总结
查看>>
vue-13-插件
查看>>
vs2015 报的字符串超长错误
查看>>
Flex的学习资源
查看>>
千万别信“创业要胆大”这种鬼话!有些人只是后盾够强
查看>>
PL/SQL 09 包 package
查看>>
Java 8 特性 —— 方法引用
查看>>
CSS3环形动画菜单
查看>>
动态设置 layui select 为选中状态
查看>>
Apache不定时宕机
查看>>
[译] 所有你需要知道的关于完全理解 Node.js 事件循环及其度量
查看>>
Unity3D初学心得
查看>>
学破解 <二> PE格式之IMAGE_NT_HEADERS
查看>>
laravel homestead
查看>>
https和http共存的nginx简单配置
查看>>