How to Install Java 14 on CentOS/RHEL 7/8 & Fedora

Java is a secure, stable, and well known, general-purpose programming language and computing technology platform with many interconnected capabilities.

To run Java-based applications, you must have Java installed on your server. You mostly need the Java Runtime Environment (JRE), a collection of software components used to run Java applications on the Linux machine.

If you want to develop software applications for Java, you need to install the Oracle Java Development Kit (JDK), which comes with a complete JRE package with tools for developing, debugging, and monitoring Java applications and it is an Oracle’s supported Java SE (Standard Edition) version.

Note: If you are looking for an open-source and free JDK version, install the OpenJDK which provides the same features and performance as Oracle JDK under the GPL license.

At the time of writing this article, OpenJDK 11 is the current LTS version of Java to be installed using the following command from the default repositories:

# yum install java-11-openjdk-devel
# java -version
Sample Output
openjdk 11.0.8 2020-07-14 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.8+10-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.8+10-LTS, mixed mode, sharing)

In this article, we will show you how to install Oracle OpenJDK 14 in RHEL 8/7/6, CentOS 8/7/6, and Fedora 30-32 to develop and run Java applications.

Installing Oracle OpenJDK 14 in CentOS/RHEL and Fedora

To install Oracle OpenJDK 14, you need to download the production-ready OpenJDK 14 from the Java SE Downloads page or run the following wget command to download and install it as shown.

# wget --no-check-certificate -c --header "Cookie: oraclelicense=accept-securebackup-cookie" https://download.oracle.com/otn-pub/java/jdk/14.0.2+12/205943a0976c4ed48cb16f1043c5c647/jdk-14.0.2_linux-x64_bin.rpm

Install the package using the following command:

# yum localinstall jdk-14.0.2_linux-x64_bin.rpm 

If you have more than one Java version installed on the system, you need to set the default version using the alternatives command as shown.

# alternatives --config java
Sample Output
There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
 + 1           java-11-openjdk.x86_64 (/usr/lib/jvm/java-11-openjdk-11.0.8.10-0.el8_2.x86_64/bin/java)
*  2           /usr/java/jdk-14.0.2/bin/java

Enter to keep the current selection[+], or type selection number: 2

Just, enter the number to set the default Java version on the system.

Finally, check the Java version.

# java -version
Sample Output
java version "14.0.2" 2020-07-14
Java(TM) SE Runtime Environment (build 14.0.2+12-46)
Java HotSpot(TM) 64-Bit Server VM (build 14.0.2+12-46, mixed mode, sharing)

Congratulations! You’ve successfully installed the latest version of Oracle OpenJDK 14 in RHEL 8/7/6, CentOS 8/7/6, and Fedora 30-32 to develop and run Java applications.

If you liked this article, then do subscribe to email alerts for Linux tutorials. If you have any questions or doubts? do ask for help in the comments section.

If You Appreciate What We Do Here On TecMint, You Should Consider:

TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.

Support Us

We are thankful for your never ending support.

30 thoughts on “How to Install Java 14 on CentOS/RHEL 7/8 & Fedora”

  1. REPOST

    Hi,

    I installed OpenJDK 13 the I did the global shell start-up file.

    # vi /etc/environment
    

    Added:

    Export JAVA_HOME=/opt/jdk-13/ 
    Export PATH=$PATH:/opt/jdk-13/bin
    

    Then run the following command to activate it.

    # source /etc/environment
    

    Then after that when I log in to the server again, it gave me this.

    -bash: tty: command not found
    -bash: ls: command not found
    /usr/libexec/grepconf.sh: line 5: grep: command not found
    -bash-4.2$
    

    Now I can’t run any commands. How should I recover this?

    thanks.

    Reply
    • Please read everything before copy-pasting any command.

      For everyone who has this problem you can just clear the “Export PATH=$PATH:/opt/jdk-13/bin” line (leave the definition of JAVA_HOME there).

      To clear the line you can call your text editor using the complete path from the root to it and then edit the file, for example “/bin/vi /etc/environment” and then log in again (or reboot) to source it.

      This will resolve your problem but will create many, in fact, you won’t be able to call any of the java commands.

      To resolve this problem you can do the following (if you want to stick with this installation), I suggest to verify before if any of those new jdk-13/bin/files already exists in the /usr/bin folder (overwriting them without caution may cause problems):

      # ln -s /opt/jdk-13/bin/* /usr/bin/
      

      this creates symbolic links for each new jdk-13/bin file in the /usr/bin folder.

      If some files already exist it is your own decision if you want to overwrite them (it may cause some problems).

      To overwrite the already existing files the command is:

      # ln -sf /opt/jdk-13/bin/* /usr/bin/
      

      tI does the same thing as the previous command but it forces overwriting over already existing files with the same name as the new ones.

      What this command does is basically creating links in the /bin folder so that you don’t need to overwrite the $PATH variable to access them.

      I don’t know if it is the correct method to resolve this problem but it worked for me, I’m on CentOS 8.

      Reply
  2. Hi,

    I installed OpenJDK 13 the I did the global shell start-up file.

    # vi /etc/environment
    

    Added:

    Export JAVA_HOME=/opt/jdk-13/ 
    Export PATH=$PATH:/opt/jdk-13/bin
    

    Then ran the following command to active it.

    # source /etc/environment
    

    Then after that when I log in to the server again, it gave me this.

    -bash: tty: command not found
    -bash: ls: command not found
    /usr/libexec/grepconf.sh: line 5: grep: command not found
    -bash-4.2$

    Now I can’t run any commands. How should I recover this?

    thanks.

    Reply
  3. I was looking for a way to install OpenJDK 8 on RHEL 5, as the Oracle version comes with a heavy price for commercial use. Do you have any insight into this? Is IBM Java available for RHEL 5 in RPM binary form?

    Reply
    • @DMan,
      I don’t think that latest version of JDK 8 works on RHEL 5, due to version issues. I suggest you to do a system upgrade..

      Reply
        • @Hari,

          I don’t think that latest Java version will support on older CentOS 5.11, why not upgrade to newer CentOS version?

          Reply
          • I’m not sure if it is technically supported on RHEL 5, but it is installable. The process is a hassle though. First, uninstall previous versions of Java. You may run into dependency issues while trying to uninstall the previous versions. The only way I found to fix this is to search for the specific java rpm (rpm -qa |grep -i java) and then remove that specific rpm: rpm -e –nodeps java-1.x.x. This is generally a really, really bad idea. However, if you’re in a jam, that should work.

            Then install the jre or jdk-1.8 rpm from oracles web site using either yum install jre-1.8.xx.rpm or rpm -vhi jre-1.8.xx.rpm.

            You’ll have to update /etc/alternatives. You should be able to search on how to do this. There is a nice article on unixmen, but I don’t know the rules for posting direct links on this site.

            Hope that helps.

  4. Hello I did every step you mention, but on Centos7 after check java -version it displays 1.7.0_u85 :-( I tried also install it from Centos7 repo and the result is same.

    Reply
    • @Ales,
      I think you already have older version of Java installed, better remove it with yum and re-install the latest version as described in this article.

      Reply
  5. Hello from the above we can download the java and how to install it is some what not clear for me..After that Install java in Linux and setting java as environment variables are not getting from above info..U have specified only rpm command..will it result of getting “environment variables setting” automatically?? & That is the only command enough for the task? clear me pls..and revert me to “[email protected]” Thank you…

    Reply

Leave a Reply to Minal Cancel reply

Have a question or suggestion? Please leave a comment to start the discussion. Please keep in mind that all comments are moderated and your email address will NOT be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.