How to Install Oracle Java in Oracle Cloud Infrastructure

December 19, 2019 | 2 minute read
Text Size 100%:

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:

Copied to Clipboard
Error: Could not Copy
Copied to Clipboard
Error: Could not Copy
$ 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:

Copied to Clipboard
Error: Could not Copy
Copied to Clipboard
Error: Could not Copy
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:

Copied to Clipboard
Error: Could not Copy
Copied to Clipboard
Error: Could not Copy
$ sudo yum install jdk-14.0.1

To confirm the Java version:

Copied to Clipboard
Error: Could not Copy
Copied to Clipboard
Error: Could not Copy
$ 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:

Copied to Clipboard
Error: Could not Copy
Copied to Clipboard
Error: Could not Copy
$ sudo yum install -y jdk1.8

The alternatives command shows that two programs provide java:

Copied to Clipboard
Error: Could not Copy
Copied to Clipboard
Error: Could not Copy
$ 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):

Copied to Clipboard
Error: Could not Copy
Copied to Clipboard
Error: Could not Copy
$ 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)

Conclusion

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.

Sergio Leunissen


Previous Post

Fighting Diabetes With Technology - How I Built An App To Count Carbs And Calculate Insulin Doses

Todd Sharp | 9 min read

Next Post


Publishing To Object Storage From Oracle Streaming Service

Todd Sharp | 7 min read
Oracle Chatbot
Disconnected