Install JDK with "yum" Command

This section provides a tutorial on how to download and install JDK packages using 'yum' command on CentOS systems. It will automatically install dependencies.

Actually, the YUM (Yellowdog Updater, Modified) tool on CentOS is much better than the RPM (Red Hat Package Manager). Here is what I did to install Open JDK 1.8 on my CentOS system.

1. Query existing JDK 1.6 base package. No updates available.

herong$ yum info java-1.6.0-openjdk

...
Installed Packages
Name        : java-1.6.0-openjdk
Arch        : i686
Epoch       : 1
Version     : 1.6.0.41
Release     : 1.13.13.1.el6_8
Size        : 73 M
Repo        : installed

2. Query existing JDK 1.7 base package. Update of 1.7.0.241 is available. I can install it, if needed.

herong$ yum info java-1.7.0-openjdk
Installed Packages
Name        : java-1.7.0-openjdk
Arch        : i686
Epoch       : 1
Version     : 1.7.0.161
...

Available Packages
Name        : java-1.7.0-openjdk
Arch        : i686
Epoch       : 1
Version     : 1.7.0.241

3. Query JDK 1.8 base package. It is available!

herong$ yum info java-1.8.0-openjdk

Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: hkg.mirror.rackspace.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
Available Packages
Name        : java-1.8.0-openjdk
Arch        : i686
Epoch       : 1
Version     : 1.8.0.232.b09
Release     : 1.el6_10
Size        : 219 k

4. Install JDK 1.8 base package with "root" account. "yum" is smart to automatically install dependencies.

herong# yum install java-1.8.0-openjdk

Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
...
Resolving Dependencies
...
Total download size: 34 M
Is this ok [y/N]: y
...
Installed:
  java-1.8.0-openjdk.i686 1:1.8.0.232.b09-1.el6_10

Dependency Installed:
  java-1.8.0-openjdk-headless.i686 1:1.8.0.232.b09-1.el6_10

Dependency Updated:
  nspr.i686 0:4.21.0-1.el6_10
  nss.i686 0:3.44.0-7.el6_10
  nss-softokn.i686 0:3.44.0-6.el6_10
  nss-softokn-freebl.i686 0:3.44.0-6.el6_10
  nss-sysinit.i686 0:3.44.0-7.el6_10
  nss-tools.i686 0:3.44.0-7.el6_10
  nss-util.i686 0:3.44.0-1.el6_10

5. Verify the Open JDK base component, JRE (Java Runtime Environment). I see the "jre" sub-directory.

herong# ls -l /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-1.el6_10.i386
drwxr-xr-x. 4 root root 4096 Jan  2 16:33 jre

6. Install the JDK 1.8 "devel" package.

herong# yum install java-1.8.0-openjdk-devel

...
Total download size: 10 M
Installed size: 40 M
Is this ok [y/N]: y

...
Installed:
  java-1.8.0-openjdk-devel.i686 1:1.8.0.232.b09-1.el6_10

6. Verify the full Open JDK installation.

herong$ ls -l /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.232.b09-1.el6_10.i386
drwxr-xr-x. 2 root root 4096 Jan  2 16:37 bin
drwxr-xr-x. 3 root root 4096 Jan  2 16:37 include
drwxr-xr-x. 4 root root 4096 Jan  2 16:33 jre
drwxr-xr-x. 3 root root 4096 Jan  2 16:37 lib
drwxr-xr-x. 2 root root 4096 Jan  2 16:37 tapset

herong$ java -version
openjdk version "1.8.0_232"
OpenJDK Runtime Environment (build 1.8.0_232-b09)
OpenJDK Server VM (build 25.232-b09, mixed mode)

herong$ javac -version
javac 1.8.0_232

Very nice. I have Open JDK 1.8 fully installed on my CentOS 6 now. Don't try Open JDK 9. It seems not available yet for CentOS 6 systems.

Table of Contents

 About This JDK Tutorial Book

JDK (Java Development Kit)

 What Is JDK

 Download and Install JDK 20 on macOS

 Download and Install JDK 17 on Windows

 Writing My First Java Program

 Adding JDK "bin" Directory to Path Setting

 JDK Documentation Installation

 Check JDK Version on CentOS

 Install JDK with "rpm" Command

Install JDK with "yum" Command

 Java Date-Time API

 Date, Time and Calendar Classes

 Date and Time Object and String Conversion

 Number Object and Numeric String Conversion

 Locales, Localization Methods and Resource Bundles

 Calling and Importing Classes Defined in Unnamed Packages

 HashSet, Vector, HashMap and Collection Classes

 Character Set Encoding Classes and Methods

 Character Set Encoding Maps

 Encoding Conversion Programs for Encoded Text Files

 Java Logging

 Socket Network Communication

 Datagram Network Communication

 DOM (Document Object Model) - API for XML Files

 SAX (Simple API for XML)

 DTD (Document Type Definition) - XML Validation

 XSD (XML Schema Definition) - XML Validation

 XSL (Extensible Stylesheet Language)

 Message Digest Algorithm Implementations in JDK

 Private key and Public Key Pair Generation

 PKCS#8/X.509 Private/Public Encoding Standards

 Digital Signature Algorithm and Sample Program

 "keytool" Commands and "keystore" Files

 KeyStore and Certificate Classes

 Secret Key Generation and Management

 Cipher - Encryption and Decryption

 The SSL (Secure Socket Layer) Protocol

 SSL Socket Communication Testing Programs

 SSL Client Authentication

 HTTPS (Hypertext Transfer Protocol Secure)

 Outdated Tutorials

 References

 Full Version in PDF/EPUB