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
=======================================================================================================================================================
Installing:
 java-1.8.0-openjdk                           x86_64                  1:1.8.0.252.b09-2.el8_1                     ol8_appstream                  320 k
Installing dependencies:
 java-1.8.0-openjdk-headless                  x86_64                  1:1.8.0.252.b09-2.el8_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 
libnssckbi.so.x86_64  	auto  	/usr/lib64/pkcs11/p11-kit-trust.so
python                	auto  	/usr/libexec/no-python
ifup                  	auto  	/usr/libexec/nm-ifup
cifs-idmap-plugin     	auto  	/usr/lib64/cifs-utils/cifs_idmap_sss.so
nmap                  	auto  	/usr/bin/ncat
libwbclient.so.0.15-64	auto  	/usr/lib64/samba/wbclient/libwbclient.so.0.15
java                  	auto  	/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el8_1.x86_64/jre/bin/java
jre_openjdk           	auto  	/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el8_1.x86_64/jre
jre_11                	auto  	/usr/lib/jvm/java-11-openjdk-11.0.7.10-1.el8_1.x86_64
jre_11_openjdk        	auto  	/usr/lib/jvm/jre-11-openjdk-11.0.7.10-1.el8_1.x86_64
jre_1.8.0             	auto  	/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el8_1.x86_64/jre
jre_1.8.0_openjdk     	auto  	/usr/lib/jvm/jre-1.8.0-openjdk-1.8.0.252.b09-2.el8_1.x86_64

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-11.0.7.10-1.el8_1.x86_64/bin/java)
*  2           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.252.b09-2.el8_1.x86_64/jre/bin/java)

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)

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

Installing Java 11 on Oracle Linux 8

LEAVE A REPLY

Please enter your comment!
Please enter your name here

2 × 4 =