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 from the OCI yum service.

Installing Oracle Java

Oracle Java RPMs are available for Oracle Linux 7 and Oracle Linux 8 in the ol7_oci_included and ol8_oci_included repositories respectively. Current Oracle Linux images are provisioned with these repositories installed and enabled.

As of this writing, the repositories contain Oracle Java 8, 11, 12, 13, and 14 for Oracle Linux 7:

$ 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-11.0.7.x86_64                                                           2000:11.0.7-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 
jdk-14.x86_64                                                               2000:14-ga                                                                    ol7_oci_included 
jdk-14.0.1.x86_64                                                           2000:14.0.1-ga                                                                ol7_oci_included 
jdk1.8.x86_64                                                               2000:1.8.0_251-fcs                                                            ol7_oci_included 

...and Oracle Java 8, 11, and 14 for Oracle Linux 8:

yum list jdk*
Last metadata expiration check: 6:09:09 ago on Mon 27 Apr 2020 11:57:02 AM GMT.
Installed Packages
jdk-11.0.7.x86_64                                                            2000:11.0.7-ga                                                                ol8_oci_included
jdk-14.0.1.x86_64                                                            2000:14.0.1-ga                                                                ol8_oci_included
jdk1.8.x86_64                                                                2000:1.8.0_251-fcs                                                            ol8_oci_included

To install Oracle Java 14, version 14.0.1:

$ sudo yum install jdk-14.0.1

To confirm the Java version:

$ java -version
java version "14.0.1" 2020-04-14
Java(TM) SE Runtime Environment (build 14.0.1+7)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.1+7, 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-14.0.1/bin/java
   2           /usr/java/jdk1.8.0_251-amd64/jre/bin/java

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

$ java -version
java version "1.8.0_251"
Java(TM) SE Runtime Environment (build 1.8.0_251-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.251-b08, 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 service, installation is greatly simplified. Try it for free with Oracle Cloud Free Tier.

Join the discussion

Comments ( 5 )
  • Muneer Tuesday, June 25, 2019

    the step to enable repository is not working.

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

    i get below Error.
    failure: repodata/repomd.xml from ol7_ociyum_config: [Errno 256] No more mirrors to try.
    http://yum.oracle.com/repo/OracleLinux/OL7/oci/included/x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 404 - Not Found

    please Help.
  • Sergio Tuesday, June 25, 2019
    @Muneer, are you running these yum commands from a system running in Oracle Cloud Infrastructure? If so, please provide details of your environment here, referring to this blog post.
  • Cristi Wednesday, April 8, 2020
    Hi - I am an OCI subscriber and I am trying to setup an Oracle Linux 8. I tried to install Oracle JDK but all
    I found in the repositories (oci-release-el8, oci-included-release-el8) was OpenJdk.
    Can you provide any support here (how can I get from the repositories Oracle's JDK)?
  • Sergio Thursday, April 23, 2020
    @Cristi: Oracle JDK 14 was just added to the OCI yum service. Other releases will follow shortly.
  • Suyash JOshi Thursday, May 14, 2020
    This is helpful, alternatively one can just provision the "Developer Image" from OCI Marketplace that already has JDK pre-installed along with other developer environments.
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.