Break New Ground

How to Install Oracle Java in Oracle Cloud Infrastructure

Oracle Java Support and Updates Included in Oracle Cloud Infrastructure


Note: this post was updated to reflect updated Oracle Java versions


We recently announced that Oracle Java, Oracle’s widely adopted and proven Java Development Kit, is now included with Oracle Cloud Infrastructure subscriptions at no extra cost.

In this blog post I show how to install Oracle Java on Oracle Linux running in an OCI compute shape by using RPMs available yum servers available within OCI.

Installing Oracle Java

The Oracle Java RPMs are in the ol7_oci_included repository on Oracle Linux yum server accessible from within OCI.

Current Oracle Linux images come with this repository enabled. If it's not already enabled:

$ sudo yum install -y --enablerepo=ol7_ociyum_config oci-included-release-el7

As of this writing, the repository contains Oracle Java 8, 11, 12 and 13.

$ yum list jdk*
Loaded plugins: langpacks, ulninfo
Available Packages
jdk-11.0.3.x86_64                                             2000:11.0.3-ga                                                  ol7_oci_included
jdk-11.0.4.x86_64                                             2000:11.0.4-ga                                                  ol7_oci_included
jdk-11.0.5.x86_64                                             2000:11.0.5-ga                                                  ol7_oci_included
jdk-12.0.1.x86_64                                             2000:12.0.1-ga                                                  ol7_oci_included
jdk-12.0.2.x86_64                                             2000:12.0.2-ga                                                  ol7_oci_included
jdk-13.x86_64                                                 2000:13-ga                                                      ol7_oci_included
jdk-13.0.1.x86_64                                             2000:13.0.1-ga                                                  ol7_oci_included
jdk1.8.x86_64                                                 2000:1.8.0_231-fcs                                              ol7_oci_included

To install Oracle Java 12, version 12.0.2:

$ sudo yum install jdk-12.0.2

To confirm the Java version:

$ java -version
java version "12.0.2" 2019-07-16
Java(TM) SE Runtime Environment (build 12.0.2+9)
Java HotSpot(TM) 64-Bit Server VM (build 12.0.2+9, mixed mode, sharing)

Multiple JDK versions and setting the default

If you install multiple version of the JDK, you may want to set the default version using alternatives. For example, let’s first install Oracle Java 8:

$ sudo yum install -y jdk1.8

The alternatives command shows that two programs provide java:

$ sudo alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
*+ 1           /usr/java/jdk-12.0.2/bin/java
   2           /usr/java/jdk1.8.0_231-amd64/jre/bin/java

Choosing selection 2 sets the default to JDK 1.8 (Oracle Java 8):

$ $ java -version
java version "1.8.0_231"
Java(TM) SE Runtime Environment (build 1.8.0_231-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.231-b11, mixed mode)


Oracle Cloud Infrastructure includes Oracle Java —with support and updates— at no additional cost. By providing Oracle Java RPMs in OCI’s yum servers, installation is greatly simplified. Try it for free with Oracle Cloud Free Tier.

Join the discussion

Comments ( 2 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.

Recent Content