The Oracle team has discontinued the security updates for Java 8. Also released the latest Java 11 LTS version. Java 11 has been released for general availability with the many featured enhancements. You can read the details here. This article will help you to install Oracle Java 11 on CentOS 7/6, RHEL 7/6 and Fedora 28/27/26/25 system.
Step 1 – Download Java 11
Download the latest Java SE Development Kit 11 LTS release from its official download page or use following commands to download from command line.
wget --no-cookies --no-check-certificate --header "Cookie: oraclelicense=accept-securebackup-cookie" \ http://download.oracle.com/otn-pub/java/jdk/11+28/55eed80b163941c8885ad9298e6d786a/jdk-11_linux-x64_bin.tar.gz
Then extract the downloaded archive
tar xzf jdk-11_linux-x64_bin.tar.gz -C /usr/local
Step 2 – Install Java 11
After extracting archive file use alternatives command to install it. alternatives command is available in chkconfig package.
cd /usr/local/jdk-11/ alternatives --install /usr/bin/java java /usr/local/jdk-11/bin/java 2 alternatives --config java
According to the above screenshot, there are 3 versions installed. Java 11 is listed on number 3, So entered 3 and press Enter. Now Java 11 is installed as default Java on my CentOS system.
There are some other binaries to set as default for JDK installation. Execute the commands to set javac and jar as default:
alternatives --install /usr/bin/jar jar /usr/local/jdk-11/bin/jar 2 alternatives --install /usr/bin/javac javac /usr/local/jdk-11/bin/javac 2 alternatives --set jar /usr/local/jdk-11/bin/jar alternatives --set javac /usr/local/jdk-11/bin/javac
Step 3 – Check Java Version
Check the installed Java version on your system using the following command.
[email protected] ~# java -version java version "11" 2018-09-25 Java(TM) SE Runtime Environment 18.9 (build 11+28) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11+28, mixed mode)
Step 4 – Setup Java Environment Variables
Most of the Java-based applications uses environment variables to work. Set the Java environment variables using following commands
- Setup JAVA_HOME Variable
export JAVA_HOME=/usr/local/jdk-11 export PATH=$PATH:/usr/local/jdk-11/bin
Also put all above environment variables in /etc/environment file for auto loading on system boot.