JDK环境部署
JDK环境部署
作者:尹正杰
版权声明:原创作品,谢绝转载!否则将追究法律责任。
一.JDK版本说明
1>.Open JDK 这个不多说,免费的开源实现,以 GPL License 发布,很多 Linux 发行版中都会包含这个 Open JDK 。参与开发的大佬们有 Oracle、RedHat (已被 IBM 收购)、Azul System、IBM、Apple、SAP。 2>.Oracle JDK 就是我们常说的 Java JDK,也是最常用的一个,是 Oracle 公司(收购了开发 Java 的 Sun 公司)对 Java SE 的实现。如果更详细分的话,可以分为 Oracle JDK 和 Oracle JRE。比如你想玩 Minecraft 这样需要 Java 的游戏,那只需要从 java.com 下载一个 JRE 就够了。如果你想基于 Java 做开发,那就需要从 Oracle Technology Network(OTN)网站上下载 JDK 了。 假设 JDK 8u192 是 2018 年的最后一个 Update,你下载并且安装了,那可以继续免费使用下去,没有任何问题。但是从 2019 年 1 月开始,如果你还想获取 JDK 的 Update,对不起,你需要付费订阅。这个订阅服务的价格是这样的:对于 PC,每用户每月是 2.5 美元,对于服务器/云部署,每个 processor 每月是 25 美元,当然,数量多的话可以打折。 3>.其他公司提供的 JDK 有实力的大公司,都有可能开发自己的 JDK ,比如 IBM ,肯定要为自家的操作系统 AIX,还有 z/OS 开发 SDK。HP、SAP 也有自己的 JDK,可以为自己的硬件和软件做定制。 Oracle Java SE Advanced、Java SE Advanced Desktop、Java SE Suite 这名字很长,也有点费解,简单来说,这是个收费的服务, 是 Oracle 为企业级用户提供的高级工具和功能,可以监控、部署、管理企业级的 Java 程序,与此同时,你还可以下载那些老版本的 JDK 及其 Update。换句话说,如果你购买了这个服务,自然就不用担心什么 JDK Update 收费的问题。但是问题在于,到底有多少公司再使用这个服务? 如果你的公司在使用,欢迎告知。所以我猜测 Oracle 耍了一点小手段, 以后不要这个收费的服务了,把这些高级的功能加上 JDK Update 打包,统一成一个新的服务,就是之前说的订阅服务。 注意,我这里说的都是公司,都是商业用途,如果只是个人学习 Java 的话,没什么影响! 以上文章参自互联网:https://baijiahao.baidu.com/s?id=1620513576396123558&wfr=spider&for=pc
二.Open JDK的安装部署
1>.在CentOS7.6图形界面安装时,默认会给咱们安装该服务
[root@node101.yinzhengjie.org.cn ~]# which java /usr/bin/java [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /usr/bin/java lrwxrwxrwx. 1 root root 22 Mar 11 13:57 /usr/bin/java -> /etc/alternatives/java [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /etc/alternatives/java lrwxrwxrwx. 1 root root 74 Mar 11 13:57 /etc/alternatives/java -> /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.191-2.6.15.5.el7.x86_64/jre/bin/java [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# rpm -qa *openjdk* java-1.7.0-openjdk-headless-1.7.0.191-2.6.15.5.el7.x86_64 java-1.7.0-openjdk-1.7.0.191-2.6.15.5.el7.x86_64 java-11-openjdk-headless-11.0.ea.28-7.el7.x86_64 java-11-openjdk-11.0.ea.28-7.el7.x86_64 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# java -version java version "1.7.0_191" OpenJDK Runtime Environment (rhel-2.6.15.5.el7-x86_64 u191-b01) OpenJDK 64-Bit Server VM (build 24.191-b01, mixed mode) [root@node101.yinzhengjie.org.cn ~]#
2>. CentOs的yum源默认就有openjdk的rpm包
[root@node101.yinzhengjie.org.cn ~]# yum search jdk Loaded plugins: fastestmirror, langpacks Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast Determining fastest mirrors * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com ===================================================================================================================== N/S matched: jdk ===================================================================================================================== copy-jdk-configs.noarch : JDKs configuration files copier 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-accessibility.x86_64 : OpenJDK accessibility connector 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-headless.x86_64 : The OpenJDK runtime environment without audio and video support 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.i686 : OpenJDK Runtime Environment java-1.8.0-openjdk.x86_64 : OpenJDK Runtime Environment 8 java-1.8.0-openjdk-accessibility.i686 : OpenJDK accessibility connector java-1.8.0-openjdk-accessibility.x86_64 : OpenJDK accessibility connector java-1.8.0-openjdk-accessibility-debug.i686 : OpenJDK accessibility connector for packages with debug on java-1.8.0-openjdk-accessibility-debug.x86_64 : OpenJDK 8 accessibility connector for packages with debug on java-1.8.0-openjdk-debug.i686 : OpenJDK Runtime Environment with full debug on java-1.8.0-openjdk-debug.x86_64 : OpenJDK Runtime Environment 8 with full debug on java-1.8.0-openjdk-demo.i686 : OpenJDK Demos java-1.8.0-openjdk-demo.x86_64 : OpenJDK Demos 8 java-1.8.0-openjdk-demo-debug.i686 : OpenJDK Demos with full debug on java-1.8.0-openjdk-demo-debug.x86_64 : OpenJDK Demos 8 with full debug on java-1.8.0-openjdk-devel.i686 : OpenJDK Development Environment java-1.8.0-openjdk-devel.x86_64 : OpenJDK Development Environment 8 java-1.8.0-openjdk-devel-debug.i686 : OpenJDK Development Environment with full debug on java-1.8.0-openjdk-devel-debug.x86_64 : OpenJDK Development Environment 8 with full debug on java-1.8.0-openjdk-headless.i686 : OpenJDK Runtime Environment java-1.8.0-openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment 8 java-1.8.0-openjdk-headless-debug.i686 : OpenJDK Runtime Environment with full debug on java-1.8.0-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full debug on java-1.8.0-openjdk-javadoc.noarch : OpenJDK 8 API documentation java-1.8.0-openjdk-javadoc-debug.noarch : OpenJDK 8 API documentation for packages with debug on java-1.8.0-openjdk-javadoc-zip.noarch : OpenJDK 8 API documentation compressed in single archive java-1.8.0-openjdk-javadoc-zip-debug.noarch : OpenJDK 8 API documentation compressed in single archive for packages with debug on java-1.8.0-openjdk-src.i686 : OpenJDK Source Bundle java-1.8.0-openjdk-src.x86_64 : OpenJDK Source Bundle 8 java-1.8.0-openjdk-src-debug.i686 : OpenJDK Source Bundle for packages with debug on java-1.8.0-openjdk-src-debug.x86_64 : OpenJDK Source Bundle 8 for packages with debug on java-11-openjdk.i686 : OpenJDK Runtime Environment 11 java-11-openjdk.x86_64 : OpenJDK Runtime Environment 11 java-11-openjdk-debug.i686 : OpenJDK Runtime Environment 11 with full debug on java-11-openjdk-debug.x86_64 : OpenJDK Runtime Environment 11 with full debug on java-11-openjdk-demo.i686 : OpenJDK Demos 11 java-11-openjdk-demo.x86_64 : OpenJDK Demos 11 java-11-openjdk-demo-debug.i686 : OpenJDK Demos 11 with full debug on java-11-openjdk-demo-debug.x86_64 : OpenJDK Demos 11 with full debug on java-11-openjdk-devel.i686 : OpenJDK Development Environment 11 java-11-openjdk-devel.x86_64 : OpenJDK Development Environment 11 java-11-openjdk-devel-debug.i686 : OpenJDK Development Environment 11 with full debug on java-11-openjdk-devel-debug.x86_64 : OpenJDK Development Environment 11 with full debug on java-11-openjdk-headless.i686 : OpenJDK Headless Runtime Environment 11 java-11-openjdk-headless.x86_64 : OpenJDK Headless Runtime Environment 11 java-11-openjdk-headless-debug.i686 : OpenJDK Runtime Environment with full debug on java-11-openjdk-headless-debug.x86_64 : OpenJDK Runtime Environment with full debug on java-11-openjdk-javadoc.i686 : OpenJDK 11 API documentation java-11-openjdk-javadoc.x86_64 : OpenJDK 11 API documentation java-11-openjdk-javadoc-debug.i686 : OpenJDK 11 API documentation for packages with debug on java-11-openjdk-javadoc-debug.x86_64 : OpenJDK 11 API documentation for packages with debug on java-11-openjdk-javadoc-zip.i686 : OpenJDK 11 API documentation compressed in single archive java-11-openjdk-javadoc-zip.x86_64 : OpenJDK 11 API documentation compressed in single archive java-11-openjdk-javadoc-zip-debug.i686 : OpenJDK 11 API documentation compressed in single archive for packages with debug on java-11-openjdk-javadoc-zip-debug.x86_64 : OpenJDK 11 API documentation compressed in single archive for packages with debug on java-11-openjdk-jmods.i686 : JMods for OpenJDK 11 java-11-openjdk-jmods.x86_64 : JMods for OpenJDK 11 java-11-openjdk-jmods-debug.i686 : JMods for OpenJDK 11 with full debug on java-11-openjdk-jmods-debug.x86_64 : JMods for OpenJDK 11 with full debug on java-11-openjdk-src.i686 : OpenJDK Source Bundle 11 java-11-openjdk-src.x86_64 : OpenJDK Source Bundle 11 java-11-openjdk-src-debug.i686 : OpenJDK Source Bundle for packages with debug on java-11-openjdk-src-debug.x86_64 : OpenJDK Source Bundle 11 for packages with debug on ldapjdk-javadoc.noarch : Javadoc for ldapjdk icedtea-web.x86_64 : Additional Java components for OpenJDK - Java browser plug-in and Web Start implementation ldapjdk.noarch : The Mozilla LDAP Java SDK Name and summary matches only, use "search all" for everything. [root@node101.yinzhengjie.org.cn ~]#
3>.安装OpenJDK1.8
[root@node101.yinzhengjie.org.cn ~]# yum -y install java-1.8.0-openjdk-devel Loaded plugins: fastestmirror, langpacks Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package java-1.8.0-openjdk-devel.x86_64 1:1.8.0.201.b09-2.el7_6 will be installed --> Processing Dependency: java-1.8.0-openjdk(x86-64) = 1:1.8.0.201.b09-2.el7_6 for package: 1:java-1.8.0-openjdk-devel-1.8.0.201.b09-2.el7_6.x86_64 --> Running transaction check ---> Package java-1.8.0-openjdk.x86_64 1:1.8.0.201.b09-2.el7_6 will be installed --> Processing Dependency: java-1.8.0-openjdk-headless(x86-64) = 1:1.8.0.201.b09-2.el7_6 for package: 1:java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64 --> Running transaction check ---> Package java-1.8.0-openjdk-headless.x86_64 1:1.8.0.201.b09-2.el7_6 will be installed --> Finished Dependency Resolution Dependencies Resolved ========================================================================================================================================================================================================================================== Package Arch Version Repository Size ========================================================================================================================================================================================================================================== Installing: java-1.8.0-openjdk-devel x86_64 1:1.8.0.201.b09-2.el7_6 updates 9.8 M Installing for dependencies: java-1.8.0-openjdk x86_64 1:1.8.0.201.b09-2.el7_6 updates 260 k java-1.8.0-openjdk-headless x86_64 1:1.8.0.201.b09-2.el7_6 updates 32 M Transaction Summary ========================================================================================================================================================================================================================================== Install 1 Package (+2 Dependent packages) Total download size: 42 M Installed size: 144 M Downloading packages: (1/3): java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64.rpm | 260 kB 00:00:00 (2/3): java-1.8.0-openjdk-devel-1.8.0.201.b09-2.el7_6.x86_64.rpm | 9.8 MB 00:00:11 (3/3): java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el7_6.x86_64.rpm | 32 MB 00:00:18 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Total 2.3 MB/s | 42 MB 00:00:18 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el7_6.x86_64 1/3 Installing : 1:java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64 2/3 Installing : 1:java-1.8.0-openjdk-devel-1.8.0.201.b09-2.el7_6.x86_64 3/3 Verifying : 1:java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64 1/3 Verifying : 1:java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el7_6.x86_64 2/3 Verifying : 1:java-1.8.0-openjdk-devel-1.8.0.201.b09-2.el7_6.x86_64 3/3 Installed: java-1.8.0-openjdk-devel.x86_64 1:1.8.0.201.b09-2.el7_6 Dependency Installed: java-1.8.0-openjdk.x86_64 1:1.8.0.201.b09-2.el7_6 java-1.8.0-openjdk-headless.x86_64 1:1.8.0.201.b09-2.el7_6 Complete! [root@node101.yinzhengjie.org.cn ~]#
[root@node101.yinzhengjie.org.cn ~]# java -version #安装后,他默认就会把新新安装的版本链接过去。 openjdk version "1.8.0_201" OpenJDK Runtime Environment (build 1.8.0_201-b09) OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode) [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# which java /usr/bin/java [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /usr/bin/java lrwxrwxrwx. 1 root root 22 Apr 20 18:15 /usr/bin/java -> /etc/alternatives/java [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /etc/alternatives/java #看这里,我们发现他把链接只想了openjdk1.8啦! lrwxrwxrwx. 1 root root 73 Apr 20 18:15 /etc/alternatives/java -> /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64/jre/bin/java [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# rpm -qa *openjdk* #查看已经存在的JDK版本 java-1.7.0-openjdk-headless-1.7.0.191-2.6.15.5.el7.x86_64 java-1.7.0-openjdk-1.7.0.191-2.6.15.5.el7.x86_64 java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el7_6.x86_64 java-11-openjdk-headless-11.0.ea.28-7.el7.x86_64 java-1.8.0-openjdk-devel-1.8.0.201.b09-2.el7_6.x86_64 java-11-openjdk-11.0.ea.28-7.el7.x86_64 java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]#
三.Oracle JDK安装部署(我们演示基于tar包的方式安装,我们使用软件是需要对软件配置我们jdk自定义安装对路径哟!如果基于rpm方式安装一般情况下并不需要!)
1>.打开Oracle官方网站下载相应的平台的安装包(https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html)
2>.卸载平台中已经存在的JDK版本
[root@node101.yinzhengjie.org.cn ~]# java -version openjdk version "1.8.0_201" OpenJDK Runtime Environment (build 1.8.0_201-b09) OpenJDK 64-Bit Server VM (build 25.201-b09, mixed mode) [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# rpm -qa *openjdk* java-1.7.0-openjdk-headless-1.7.0.191-2.6.15.5.el7.x86_64 java-1.7.0-openjdk-1.7.0.191-2.6.15.5.el7.x86_64 java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el7_6.x86_64 java-11-openjdk-headless-11.0.ea.28-7.el7.x86_64 java-1.8.0-openjdk-devel-1.8.0.201.b09-2.el7_6.x86_64 java-11-openjdk-11.0.ea.28-7.el7.x86_64 java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# rpm -e --nodeps java-1.7.0-openjdk-headless-1.7.0.191-2.6.15.5.el7.x86_64 #卸载JDK版本! [root@node101.yinzhengjie.org.cn ~]# rpm -e --nodeps java-1.7.0-openjdk-1.7.0.191-2.6.15.5.el7.x86_64 [root@node101.yinzhengjie.org.cn ~]# rpm -e --nodeps java-1.8.0-openjdk-headless-1.8.0.201.b09-2.el7_6.x86_64 [root@node101.yinzhengjie.org.cn ~]# rpm -e --nodeps java-11-openjdk-headless-11.0.ea.28-7.el7.x86_64 [root@node101.yinzhengjie.org.cn ~]# rpm -e --nodeps java-1.8.0-openjdk-devel-1.8.0.201.b09-2.el7_6.x86_64 [root@node101.yinzhengjie.org.cn ~]# rpm -e --nodeps java-11-openjdk-11.0.ea.28-7.el7.x86_64 [root@node101.yinzhengjie.org.cn ~]# rpm -e --nodeps java-1.8.0-openjdk-1.8.0.201.b09-2.el7_6.x86_64 [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# rpm -qa *openjdk* [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# java -version -bash: /usr/bin/java: No such file or directory [root@node101.yinzhengjie.org.cn ~]#
3>.将下载的jdk版本进行解压安装并配置环境变量(如果你下载的是rpm包的oracle jdk的话就无需配置环境变量啦!)
[root@node101.yinzhengjie.org.cn ~]# mkdir /yinzhengjie/softwares -p [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# tar -zxf jdk-8u201-linux-x64.tar.gz -C /yinzhengjie/softwares/ [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# ll /yinzhengjie/softwares/jdk1.8.0_201/ total 383856 drwxr-xr-x. 2 10 143 4096 Dec 16 03:45 bin -r--r--r--. 1 10 143 3244 Dec 16 03:45 COPYRIGHT -rw-r--r--. 1 root root 366447449 Apr 9 15:27 hadoop-2.9.2.tar.gz drwxr-xr-x. 3 10 143 4096 Dec 16 03:45 include -rw-r--r--. 1 10 143 5207434 Dec 12 17:07 javafx-src.zip drwxr-xr-x. 5 10 143 4096 Dec 16 03:45 jre drwxr-xr-x. 5 10 143 4096 Dec 16 03:45 lib -r--r--r--. 1 10 143 40 Dec 16 03:45 LICENSE drwxr-xr-x. 4 10 143 4096 Dec 16 03:45 man -r--r--r--. 1 10 143 159 Dec 16 03:45 README.html -rw-r--r--. 1 10 143 424 Dec 16 03:45 release -rw-r--r--. 1 10 143 21103945 Dec 16 03:45 src.zip -rw-r--r--. 1 10 143 108109 Dec 12 17:07 THIRDPARTYLICENSEREADME-JAVAFX.txt -r--r--r--. 1 10 143 155002 Dec 16 03:45 THIRDPARTYLICENSEREADME.txt [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# tail -3 /etc/profile #Add by yinzhengjie JAVA_HOME=/yinzhengjie/softwares/jdk1.8.0_201 PATH=$PATH:$JAVA_HOME/bin [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# source /etc/profile [root@node101.yinzhengjie.org.cn ~]# [root@node101.yinzhengjie.org.cn ~]# java -version java version "1.8.0_201" Java(TM) SE Runtime Environment (build 1.8.0_201-b09) Java HotSpot(TM) 64-Bit Server VM (build 25.201-b09, mixed mode) [root@node101.yinzhengjie.org.cn ~]#
当你的才华还撑不起你的野心的时候,你就应该静下心来学习。当你的能力还驾驭不了你的目标的时候,你就应该沉下心来历练。问问自己,想要怎样的人生。
欢迎交流学习技术交流,个人微信: "JasonYin2020"(添加时请备注来源及意图备注)
作者: 尹正杰, 博客: https://www.cnblogs.com/yinzhengjie/p/10739218.html