Table of Contents
In this article, I will take you through OpenJDK Installation on CentOS 7 with easy steps.
OpenJDK (Open Java Development Kit) is a free and open-source implementation of the Java Platform, Standard Edition (Java SE). It is the result of an effort Sun Microsystems began in 2006.
The implementation is licensed under the GNU General Public License (GNU GPL) version 2 with a linking exception. Were it not for the GPL linking exception, components that linked to the Java class library would be subject to the terms of the GPL license. OpenJDK is the official reference implementation of Java SE since version 7.
OpenJDK Installation on CentOS 7 is fairly easy and straightforward.
OpenJDK Installation on CentOS 7 with Easy Steps
Also Read: How to Install Docker Compose on Ubuntu 20.04 LTS [Step by Step]
Step 1: Update all the packages first through yum tool
[root@localhost ~]# yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.piconets.webwerks.in
* extras: mirrors.piconets.webwerks.in
* updates: mirrors.piconets.webwerks.in
No packages marked for update
Step 2: Install OpenJDK package
[root@localhost ~]# yum install java-11-openjdk
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.piconets.webwerks.in
* extras: mirrors.piconets.webwerks.in
* updates: mirrors.piconets.webwerks.in
Resolving Dependencies
--> Running transaction check
---> Package java-11-openjdk.x86_64 1:11.0.4.11-1.el7_7 will be installed
--> Processing Dependency: java-11-openjdk-headless(x86-64) = 1:11.0.4.11-1.el7_7 for package: 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: xorg-x11-fonts-Type1 for package: 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: libjpeg.so.62(LIBJPEG_6.2)(64bit) for package: 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: fontconfig(x86-64) for package: 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: libjvm.so()(64bit) for package: 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: libjpeg.so.62()(64bit) for package: 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: libjava.so()(64bit) for package: 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: libgif.so.4()(64bit) for package: 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: libXtst.so.6()(64bit) for package: 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: libXrender.so.1()(64bit) for package: 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: libXi.so.6()(64bit) for package: 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: libXext.so.6()(64bit) for package: 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: libX11.so.6()(64bit) for package: 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64
--> Running transaction check
---> Package fontconfig.x86_64 0:2.13.0-4.3.el7 will be installed
--> Processing Dependency: fontpackages-filesystem for package: fontconfig-2.13.0-4.3.el7.x86_64
--> Processing Dependency: dejavu-sans-fonts for package: fontconfig-2.13.0-4.3.el7.x86_64
---> Package giflib.x86_64 0:4.1.6-9.el7 will be installed
--> Processing Dependency: libSM.so.6()(64bit) for package: giflib-4.1.6-9.el7.x86_64
--> Processing Dependency: libICE.so.6()(64bit) for package: giflib-4.1.6-9.el7.x86_64
---> Package java-11-openjdk-headless.x86_64 1:11.0.4.11-1.el7_7 will be installed
--> Processing Dependency: tzdata-java >= 2015d for package: 1:java-11-openjdk-headless-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: copy-jdk-configs >= 3.3 for package: 1:java-11-openjdk-headless-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: pcsc-lite-libs(x86-64) for package: 1:java-11-openjdk-headless-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: lksctp-tools(x86-64) for package: 1:java-11-openjdk-headless-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: javapackages-tools for package: 1:java-11-openjdk-headless-11.0.4.11-1.el7_7.x86_64
--> Processing Dependency: cups-libs(x86-64) for package: 1:java-11-openjdk-headless-11.0.4.11-1.el7_7.x86_64
---> Package libX11.x86_64 0:1.6.7-2.el7 will be installed
--> Processing Dependency: libX11-common >= 1.6.7-2.el7 for package: libX11-1.6.7-2.el7.x86_64
--> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.6.7-2.el7.x86_64
---> Package libXext.x86_64 0:1.3.3-3.el7 will be installed
---> Package libXi.x86_64 0:1.7.9-1.el7 will be installed
---> Package libXrender.x86_64 0:0.9.10-1.el7 will be installed
---> Package libXtst.x86_64 0:1.2.3-1.el7 will be installed
---> Package libjpeg-turbo.x86_64 0:1.2.90-8.el7 will be installed
---> Package xorg-x11-fonts-Type1.noarch 0:7.5-9.el7 will be installed
--> Processing Dependency: ttmkfdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
--> Processing Dependency: ttmkfdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
--> Processing Dependency: mkfontdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
--> Processing Dependency: mkfontdir for package: xorg-x11-fonts-Type1-7.5-9.el7.noarch
--> Running transaction check
---> Package copy-jdk-configs.noarch 0:3.3-10.el7_5 will be installed
---> Package cups-libs.x86_64 1:1.6.3-40.el7 will be installed
--> Processing Dependency: libavahi-common.so.3()(64bit) for package: 1:cups-libs-1.6.3-40.el7.x86_64
--> Processing Dependency: libavahi-client.so.3()(64bit) for package: 1:cups-libs-1.6.3-40.el7.x86_64
---> Package dejavu-sans-fonts.noarch 0:2.33-6.el7 will be installed
--> Processing Dependency: dejavu-fonts-common = 2.33-6.el7 for package: dejavu-sans-fonts-2.33-6.el7.noarch
---> Package fontpackages-filesystem.noarch 0:1.44-8.el7 will be installed
---> Package javapackages-tools.noarch 0:3.4.1-11.el7 will be installed
--> Processing Dependency: python-javapackages = 3.4.1-11.el7 for package: javapackages-tools-3.4.1-11.el7.noarch
--> Processing Dependency: libxslt for package: javapackages-tools-3.4.1-11.el7.noarch
---> Package libICE.x86_64 0:1.0.9-9.el7 will be installed
---> Package libSM.x86_64 0:1.2.2-2.el7 will be installed
---> Package libX11-common.noarch 0:1.6.7-2.el7 will be installed
---> Package libxcb.x86_64 0:1.13-1.el7 will be installed
--> Processing Dependency: libXau.so.6()(64bit) for package: libxcb-1.13-1.el7.x86_64
---> Package lksctp-tools.x86_64 0:1.0.17-2.el7 will be installed
---> Package pcsc-lite-libs.x86_64 0:1.8.8-8.el7 will be installed
---> Package ttmkfdir.x86_64 0:3.0.9-42.el7 will be installed
---> Package tzdata-java.noarch 0:2019c-1.el7 will be installed
---> Package xorg-x11-font-utils.x86_64 1:7.5-21.el7 will be installed
--> Processing Dependency: libfontenc.so.1()(64bit) for package: 1:xorg-x11-font-utils-7.5-21.el7.x86_64
--> Running transaction check
---> Package avahi-libs.x86_64 0:0.6.31-19.el7 will be installed
---> Package dejavu-fonts-common.noarch 0:2.33-6.el7 will be installed
---> Package libXau.x86_64 0:1.0.8-2.1.el7 will be installed
---> Package libfontenc.x86_64 0:1.1.3-3.el7 will be installed
---> Package libxslt.x86_64 0:1.1.28-5.el7 will be installed
---> Package python-javapackages.noarch 0:3.4.1-11.el7 will be installed
--> Processing Dependency: python-lxml for package: python-javapackages-3.4.1-11.el7.noarch
--> Running transaction check
---> Package python-lxml.x86_64 0:3.2.1-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
java-11-openjdk x86_64 1:11.0.4.11-1.el7_7 updates 211 k
Installing for dependencies:
avahi-libs x86_64 0.6.31-19.el7 base 61 k
copy-jdk-configs noarch 3.3-10.el7_5 base 21 k
cups-libs x86_64 1:1.6.3-40.el7 base 358 k
dejavu-fonts-common noarch 2.33-6.el7 base 64 k
dejavu-sans-fonts noarch 2.33-6.el7 base 1.4 M
fontconfig x86_64 2.13.0-4.3.el7 base 254 k
fontpackages-filesystem noarch 1.44-8.el7 base 9.9 k
giflib x86_64 4.1.6-9.el7 base 40 k
java-11-openjdk-headless x86_64 1:11.0.4.11-1.el7_7 updates 39 M
javapackages-tools noarch 3.4.1-11.el7 base 73 k
libICE x86_64 1.0.9-9.el7 base 66 k
libSM x86_64 1.2.2-2.el7 base 39 k
libX11 x86_64 1.6.7-2.el7 base 607 k
libX11-common noarch 1.6.7-2.el7 base 164 k
libXau x86_64 1.0.8-2.1.el7 base 29 k
libXext x86_64 1.3.3-3.el7 base 39 k
libXi x86_64 1.7.9-1.el7 base 40 k
libXrender x86_64 0.9.10-1.el7 base 26 k
libXtst x86_64 1.2.3-1.el7 base 20 k
libfontenc x86_64 1.1.3-3.el7 base 31 k
libjpeg-turbo x86_64 1.2.90-8.el7 base 135 k
libxcb x86_64 1.13-1.el7 base 214 k
libxslt x86_64 1.1.28-5.el7 base 242 k
lksctp-tools x86_64 1.0.17-2.el7 base 88 k
pcsc-lite-libs x86_64 1.8.8-8.el7 base 34 k
python-javapackages noarch 3.4.1-11.el7 base 31 k
python-lxml x86_64 3.2.1-4.el7 base 758 k
ttmkfdir x86_64 3.0.9-42.el7 base 48 k
tzdata-java noarch 2019c-1.el7 updates 187 k
xorg-x11-font-utils x86_64 1:7.5-21.el7 base 104 k
xorg-x11-fonts-Type1 noarch 7.5-9.el7 base 521 k
Transaction Summary
========================================================================================================================================================================
Install 1 Package (+31 Dependent packages)
Total download size: 45 M
Installed size: 181 M
Is this ok [y/d/N]: y
Downloading packages:
(1/32): avahi-libs-0.6.31-19.el7.x86_64.rpm | 61 kB 00:00:00
(2/32): cups-libs-1.6.3-40.el7.x86_64.rpm | 358 kB 00:00:00
(3/32): fontconfig-2.13.0-4.3.el7.x86_64.rpm | 254 kB 00:00:00
(4/32): dejavu-fonts-common-2.33-6.el7.noarch.rpm | 64 kB 00:00:00
(5/32): fontpackages-filesystem-1.44-8.el7.noarch.rpm | 9.9 kB 00:00:00
(6/32): giflib-4.1.6-9.el7.x86_64.rpm | 40 kB 00:00:00
(7/32): javapackages-tools-3.4.1-11.el7.noarch.rpm | 73 kB 00:00:00
(8/32): libICE-1.0.9-9.el7.x86_64.rpm | 66 kB 00:00:00
(9/32): copy-jdk-configs-3.3-10.el7_5.noarch.rpm | 21 kB 00:00:00
(10/32): libSM-1.2.2-2.el7.x86_64.rpm | 39 kB 00:00:00
(11/32): libX11-1.6.7-2.el7.x86_64.rpm | 607 kB 00:00:00
(12/32): libX11-common-1.6.7-2.el7.noarch.rpm | 164 kB 00:00:00
(13/32): java-11-openjdk-11.0.4.11-1.el7_7.x86_64.rpm | 211 kB 00:00:00
(14/32): libXext-1.3.3-3.el7.x86_64.rpm | 39 kB 00:00:00
(15/32): libXau-1.0.8-2.1.el7.x86_64.rpm | 29 kB 00:00:00
(16/32): libXi-1.7.9-1.el7.x86_64.rpm | 40 kB 00:00:00
(17/32): libXrender-0.9.10-1.el7.x86_64.rpm | 26 kB 00:00:00
(18/32): libfontenc-1.1.3-3.el7.x86_64.rpm | 31 kB 00:00:00
(19/32): libXtst-1.2.3-1.el7.x86_64.rpm | 20 kB 00:00:00
(20/32): libjpeg-turbo-1.2.90-8.el7.x86_64.rpm | 135 kB 00:00:00
(21/32): libxslt-1.1.28-5.el7.x86_64.rpm | 242 kB 00:00:00
(22/32): lksctp-tools-1.0.17-2.el7.x86_64.rpm | 88 kB 00:00:00
(23/32): libxcb-1.13-1.el7.x86_64.rpm | 214 kB 00:00:00
(24/32): pcsc-lite-libs-1.8.8-8.el7.x86_64.rpm | 34 kB 00:00:00
(25/32): python-javapackages-3.4.1-11.el7.noarch.rpm | 31 kB 00:00:00
(26/32): ttmkfdir-3.0.9-42.el7.x86_64.rpm | 48 kB 00:00:00
(27/32): xorg-x11-font-utils-7.5-21.el7.x86_64.rpm | 104 kB 00:00:00
(28/32): tzdata-java-2019c-1.el7.noarch.rpm | 187 kB 00:00:00
(29/32): xorg-x11-fonts-Type1-7.5-9.el7.noarch.rpm | 521 kB 00:00:00
(30/32): python-lxml-3.2.1-4.el7.x86_64.rpm | 758 kB 00:00:00
(31/32): dejavu-sans-fonts-2.33-6.el7.noarch.rpm | 1.4 MB 00:00:05
(32/32): java-11-openjdk-headless-11.0.4.11-1.el7_7.x86_64.rpm | 39 MB 00:00:09
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 4.4 MB/s | 45 MB 00:00:10
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libxslt-1.1.28-5.el7.x86_64 1/32
Installing : libjpeg-turbo-1.2.90-8.el7.x86_64 2/32
Installing : fontpackages-filesystem-1.44-8.el7.noarch 3/32
Installing : libICE-1.0.9-9.el7.x86_64 4/32
Installing : libSM-1.2.2-2.el7.x86_64 5/32
Installing : dejavu-fonts-common-2.33-6.el7.noarch 6/32
Installing : dejavu-sans-fonts-2.33-6.el7.noarch 7/32
Installing : fontconfig-2.13.0-4.3.el7.x86_64 8/32
Installing : python-lxml-3.2.1-4.el7.x86_64 9/32
Installing : python-javapackages-3.4.1-11.el7.noarch 10/32
Installing : javapackages-tools-3.4.1-11.el7.noarch 11/32
Installing : libfontenc-1.1.3-3.el7.x86_64 12/32
Installing : 1:xorg-x11-font-utils-7.5-21.el7.x86_64 13/32
Installing : libXau-1.0.8-2.1.el7.x86_64 14/32
Installing : libxcb-1.13-1.el7.x86_64 15/32
Installing : pcsc-lite-libs-1.8.8-8.el7.x86_64 16/32
Installing : lksctp-tools-1.0.17-2.el7.x86_64 17/32
Installing : tzdata-java-2019c-1.el7.noarch 18/32
Installing : libX11-common-1.6.7-2.el7.noarch 19/32
Installing : libX11-1.6.7-2.el7.x86_64 20/32
Installing : libXext-1.3.3-3.el7.x86_64 21/32
Installing : libXi-1.7.9-1.el7.x86_64 22/32
Installing : libXtst-1.2.3-1.el7.x86_64 23/32
Installing : giflib-4.1.6-9.el7.x86_64 24/32
Installing : libXrender-0.9.10-1.el7.x86_64 25/32
Installing : copy-jdk-configs-3.3-10.el7_5.noarch 26/32
Installing : avahi-libs-0.6.31-19.el7.x86_64 27/32
Installing : 1:cups-libs-1.6.3-40.el7.x86_64 28/32
Installing : 1:java-11-openjdk-headless-11.0.4.11-1.el7_7.x86_64 29/32
Installing : ttmkfdir-3.0.9-42.el7.x86_64 30/32
Installing : xorg-x11-fonts-Type1-7.5-9.el7.noarch 31/32
Installing : 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64 32/32
Verifying : libXext-1.3.3-3.el7.x86_64 1/32
Verifying : libXi-1.7.9-1.el7.x86_64 2/32
Verifying : fontconfig-2.13.0-4.3.el7.x86_64 3/32
Verifying : giflib-4.1.6-9.el7.x86_64 4/32
Verifying : libXrender-0.9.10-1.el7.x86_64 5/32
Verifying : 1:xorg-x11-font-utils-7.5-21.el7.x86_64 6/32
Verifying : 1:java-11-openjdk-headless-11.0.4.11-1.el7_7.x86_64 7/32
Verifying : python-lxml-3.2.1-4.el7.x86_64 8/32
Verifying : libICE-1.0.9-9.el7.x86_64 9/32
Verifying : fontpackages-filesystem-1.44-8.el7.noarch 10/32
Verifying : ttmkfdir-3.0.9-42.el7.x86_64 11/32
Verifying : 1:cups-libs-1.6.3-40.el7.x86_64 12/32
Verifying : avahi-libs-0.6.31-19.el7.x86_64 13/32
Verifying : copy-jdk-configs-3.3-10.el7_5.noarch 14/32
Verifying : python-javapackages-3.4.1-11.el7.noarch 15/32
Verifying : dejavu-fonts-common-2.33-6.el7.noarch 16/32
Verifying : libXtst-1.2.3-1.el7.x86_64 17/32
Verifying : libX11-1.6.7-2.el7.x86_64 18/32
Verifying : libX11-common-1.6.7-2.el7.noarch 19/32
Verifying : libxcb-1.13-1.el7.x86_64 20/32
Verifying : tzdata-java-2019c-1.el7.noarch 21/32
Verifying : lksctp-tools-1.0.17-2.el7.x86_64 22/32
Verifying : libjpeg-turbo-1.2.90-8.el7.x86_64 23/32
Verifying : xorg-x11-fonts-Type1-7.5-9.el7.noarch 24/32
Verifying : libxslt-1.1.28-5.el7.x86_64 25/32
Verifying : dejavu-sans-fonts-2.33-6.el7.noarch 26/32
Verifying : pcsc-lite-libs-1.8.8-8.el7.x86_64 27/32
Verifying : javapackages-tools-3.4.1-11.el7.noarch 28/32
Verifying : 1:java-11-openjdk-11.0.4.11-1.el7_7.x86_64 29/32
Verifying : libXau-1.0.8-2.1.el7.x86_64 30/32
Verifying : libSM-1.2.2-2.el7.x86_64 31/32
Verifying : libfontenc-1.1.3-3.el7.x86_64 32/32
Installed:
java-11-openjdk.x86_64 1:11.0.4.11-1.el7_7
Dependency Installed:
avahi-libs.x86_64 0:0.6.31-19.el7 copy-jdk-configs.noarch 0:3.3-10.el7_5 cups-libs.x86_64 1:1.6.3-40.el7
dejavu-fonts-common.noarch 0:2.33-6.el7 dejavu-sans-fonts.noarch 0:2.33-6.el7 fontconfig.x86_64 0:2.13.0-4.3.el7
fontpackages-filesystem.noarch 0:1.44-8.el7 giflib.x86_64 0:4.1.6-9.el7 java-11-openjdk-headless.x86_64 1:11.0.4.11-1.el7_7
javapackages-tools.noarch 0:3.4.1-11.el7 libICE.x86_64 0:1.0.9-9.el7 libSM.x86_64 0:1.2.2-2.el7
libX11.x86_64 0:1.6.7-2.el7 libX11-common.noarch 0:1.6.7-2.el7 libXau.x86_64 0:1.0.8-2.1.el7
libXext.x86_64 0:1.3.3-3.el7 libXi.x86_64 0:1.7.9-1.el7 libXrender.x86_64 0:0.9.10-1.el7
libXtst.x86_64 0:1.2.3-1.el7 libfontenc.x86_64 0:1.1.3-3.el7 libjpeg-turbo.x86_64 0:1.2.90-8.el7
libxcb.x86_64 0:1.13-1.el7 libxslt.x86_64 0:1.1.28-5.el7 lksctp-tools.x86_64 0:1.0.17-2.el7
pcsc-lite-libs.x86_64 0:1.8.8-8.el7 python-javapackages.noarch 0:3.4.1-11.el7 python-lxml.x86_64 0:3.2.1-4.el7
ttmkfdir.x86_64 0:3.0.9-42.el7 tzdata-java.noarch 0:2019c-1.el7 xorg-x11-font-utils.x86_64 1:7.5-21.el7
xorg-x11-fonts-Type1.noarch 0:7.5-9.el7
Complete!
Step 3: Install OpenJDK-devel package
[root@localhost ~]# yum install java-11-openjdk-devel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.piconets.webwerks.in
* extras: mirrors.piconets.webwerks.in
* updates: mirrors.piconets.webwerks.in
Resolving Dependencies
--> Running transaction check
---> Package java-11-openjdk-devel.x86_64 1:11.0.4.11-1.el7_7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
java-11-openjdk-devel x86_64 1:11.0.4.11-1.el7_7 updates 3.3 M
Transaction Summary
========================================================================================================================================================================
Install 1 Package
Total download size: 3.3 M
Installed size: 5.2 M
Is this ok [y/d/N]: y
Downloading packages:
java-11-openjdk-devel-11.0.4.11-1.el7_7.x86_64.rpm | 3.3 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : 1:java-11-openjdk-devel-11.0.4.11-1.el7_7.x86_64 1/1
Verifying : 1:java-11-openjdk-devel-11.0.4.11-1.el7_7.x86_64 1/1
Installed:
java-11-openjdk-devel.x86_64 1:11.0.4.11-1.el7_7
Complete!
Step 4: Check if the package is installed properly through rpm tool
[root@localhost ~]# rpm -qa | grep -i java-11-openjdk
java-11-openjdk-11.0.4.11-1.el7_7.x86_64
java-11-openjdk-headless-11.0.4.11-1.el7_7.x86_64
java-11-openjdk-devel-11.0.4.11-1.el7_7.x86_64
Step 5: Check the Java Version
[root@localhost ~]# java -version openjdk version "11.0.4" 2019-07-16 LTS OpenJDK Runtime Environment 18.9 (build 11.0.4+11-LTS) OpenJDK 64-Bit Server VM 18.9 (build 11.0.4+11-LTS, mixed mode, sharing)
Step 6: Write your First Hello World Program
[root@localhost ~]# vi HelloWorld.java
class HelloWorld
{
public static void main(String[] args)
{
System.out.println("Hello World\n");
}
}
Step 7: Compile your HelloWorld Program
[root@localhost ~]# javac HelloWorld.java
[root@localhost ~]#
Run your Program and check the output
[root@localhost ~]# java HelloWorld Hello World
In next article, i will take you through another way of OpenJDK Installation.
For more info on Java, Please go to this link.