Install Oracle Java 11 on Fedora 29/CentOS 7

0
1922

In this guide, we are going to learn how to install Oracle Java 11 on Fedora 29/CentOS 7. There are different flavors of Java on which different applications can run on. For example, Oracle Java SE which is the official version of Java from Oracle and is not opensource. The other flavour is OpenJDK, an opensource edition of Java. This version is included on Fedora repos by default.

Install Oracle Java 11 on Fedora 29/CentOS 7

To install Oracle Java 11 on Fedora 29 or CentOS 7, follow through this guide.

Download Oracle Java 11 Archive

Navigate to Oracle Java 11 downloads page, accept the license and download the tar.gz archive.

Create Java Directory

Run the command below to create a directory where Java 11 files will reside.

mkdir /usr/java

Unpacking the Java 11 Archive

Once you have downloaded the tar.gz archive, unpack it to Java directory created above by running the command below;

tar xzf jdk-11.0.3_linux-x64_bin.tar.gz -C /usr/java

This will extract the Java 11 files under, /usr/java/jdk-11.0.3/.

Set Java 11 Default Location

Run the commands below to define Java 11 default locations.

update-alternatives --install "/usr/bin/java" "java" "/usr/java/jdk-11.0.3/bin/java" 0
update-alternatives --install "/usr/bin/javac" "javac" "/usr/java/jdk-11.0.3/bin/javac" 0
update-alternatives --install "/usr/bin/jar" "jar" "/usr/java/jdk-11.0.3/bin/jar" 0
update-alternatives --set java /usr/java/jdk-11.0.3/bin/java
update-alternatives --set javac /usr/java/jdk-11.0.3/bin/javac
update-alternatives --set jar /usr/java/jdk-11.0.3/bin/jar

Verify Java Installation

The installation in other words is done. To verify the installed version, log out of the system and login again. After that run the command below;

java --version
java 11.0.3 2019-04-16 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.3+12-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.3+12-LTS, mixed mode)

Good stuff, isn’t?

Create JAVA_HOME Environment Variable

Now that we got Java 11 installed, you can create the Java home environment variable under the /etc/environment configuration file.

echo 'JAVA_HOME="/usr/java/jdk-11.0.3"' >> /etc/environment
source /etc/environment

Verify environment variable setting.

echo $JAVA_HOME
/usr/java/jdk-11.0.3

You are done with installation of Oracle Java 11 on Fedora 29/CentOS 7. Enjoy.

You can check our guides on Oracle Java 12 by following the links below;

LEAVE A REPLY

Please enter your comment!
Please enter your name here