This comprehensive Linux guide expects that you run the following commands as root user but if you decide to run the commands as a different user then ensure that the user has
sudo
access and that you precede each of the privileged commands withsudo
Java is one of the world’s most popular programming language. Java SE 11 is the result of an industry-wide development effort involving open review, weekly builds, and extensive collaboration between Oracle engineers and members of the worldwide Java developer community via the OpenJDK Community and the JCP.
In this tutorial, we will guide you about how to install java 11 JDK/JRE on Red-Hat Based Distributions, CentOS and Fedora.
Installing Java 11
First, you need to download the Java 11 .tar file. To download the latest version CLICK HERE. At this time, java 11.0.4 is the latest version available.
After downloading, put the file into the Home directory of the root user. Then run the following commands.
root@codesposts:~$ mkdir /usr/java
root@codesposts:~$ tar xvf jdk-11.0.4_linux-x64_bin.tar.gz -C /usr/java/
Setting Up Environment Variables
After installing, we need to set the environment variables and the executable files path into your system $PATH variable, by running the below commands.
root@codesposts:~$ echo "export JAVA_HOME=/usr/java/jdk-11.0.4" >> /etc/profile
root@codesposts:~$ export JAVA_HOME=/usr/java/jdk-11.0.4
Creating Symbol Link For Java
To create the symbol link for java, run the following command:
root@codesposts:~$ alternatives --install /usr/bin/java java /usr/java/jdk-11.0.4/bin/java 2
root@codespsots:~$ lternatives --config java
There is 1 program that provides 'java'.
Selection Command
-----------------------------------------------
*+ 1 /usr/java/jdk-11.0.4/bin/java
Enter to keep the current selection[+], or type selection number:
Press Enter to keep the current selection.
Creating Symbol Link For Javac
To create the symbol link for javac, run the following command:
root@codesposts:~$ alternatives --install /usr/bin/javac javac /usr/java/jdk-11.0.4/bin/javac 2
root@codesposts:~$ alternatives --config javac
There is 1 program that provides 'javac'.
Selection Command
-----------------------------------------------
*+ 1 /usr/java/jdk-11.0.4/bin/javac
Enter to keep the current selection[+], or type selection number:
Press Enter to keep the current selection
Creating Symbol Link For Jar
To create the symbol link for jar, run the following command:
root@codesposts:~$ alternatives --install /usr/bin/jar jar /usr/java/jdk-11.0.4/bin/jar 2
root@codesposts:~$ alternatives --config jar
There is 1 program that provides 'jar'.
Selection Command
-----------------------------------------------
*+ 1 /usr/java/jdk-11.0.4/bin/jar
Enter to keep the current selection[+], or type selection number:
Press Enter.
Verifying The Version
You can verify the Java 9 version installed on your system by running the following command:
root@codesposts:~$ java --version
java version "11.0.4" 2019-08-20 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.4+13-LTS)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.4+13-LTS, mixed mode)