In our last article we discussed on the installation of Java 11 on Oracle Linux 8. Today’s tutorial will be focused on the installation of Java 8 (OpenJDK 8) on Oracle Linux 8. Java 8 is the most common Java release with lots of cool features.

Some interesting features of Java 8 are:

  • Lambda Expressions, a new language feature, has been introduced in this release. This enables you to to treat functionality as a method argument, or code as data.
  • Method references which provide an easy-to-read lambda expressions for methods that already have a name.
  • Default methods enable new functionality to be added to the interfaces of libraries and ensure binary compatibility with code written for older versions of those interfaces.
  • Repeating Annotations provide the ability to apply the same annotation type more than once to the same declaration or type use.
  • Type Annotations provide the ability to apply an annotation anywhere a type is used, not just on a declaration.
  • Improved type inference.
  • Method parameter reflection.
  • among other features

Enough with the theory, let’s now dive into the installation of Java 8 on Oracle Linux 8 server / machine.

sudo dnf install java-1.8.0-openjdk

Review dependencies to be installed and accept installation if you’re okay with it.

Dependencies resolved.
 Package                                      Architecture            Version                                     Repository                      Size
 java-1.8.0-openjdk                           x86_64                  1:                     ol8_appstream                  320 k
Installing dependencies:
 java-1.8.0-openjdk-headless                  x86_64                  1:                     ol8_appstream                   33 M

Transaction Summary
Install  2 Packages

Total download size: 33 M
Installed size: 121 M
Is this ok [y/N]: 

Setting default Java version

If you have more than one version of Java installed, use the the alternatives command to set the default version for your Applications.

List Java versions installed on Oracle Linux 8 machine.

$ sudo alternatives --list  	auto  	/usr/lib64/pkcs11/
python                	auto  	/usr/libexec/no-python
ifup                  	auto  	/usr/libexec/nm-ifup
cifs-idmap-plugin     	auto  	/usr/lib64/cifs-utils/
nmap                  	auto  	/usr/bin/ncat	auto  	/usr/lib64/samba/wbclient/
java                  	auto  	/usr/lib/jvm/java-1.8.0-openjdk-
jre_openjdk           	auto  	/usr/lib/jvm/java-1.8.0-openjdk-
jre_11                	auto  	/usr/lib/jvm/java-11-openjdk-
jre_11_openjdk        	auto  	/usr/lib/jvm/jre-11-openjdk-
jre_1.8.0             	auto  	/usr/lib/jvm/java-1.8.0-openjdk-
jre_1.8.0_openjdk     	auto  	/usr/lib/jvm/jre-1.8.0-openjdk-

Configure default java to use.

$ sudo alternatives --config java

From the list, select the Java version you want to use.

There are 2 programs which provide 'java'.

  Selection    Command
 + 1           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-
*  2           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-

Enter to keep the current selection[+], or type selection number: 2

Confirm with the java command.

$ java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)

Java Learning course:

You now have Java 8 installed on Oracle Linux 8. You can also check the guide on:

Installing Java 11 on Oracle Linux 8


Please enter your comment!
Please enter your name here