How to Install Java 13 on CentOS/RHEL 7/8 & Fedora 30/31
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 Oracle OpenJDK which provides the same features and performance as Oracle JDK under the GPL license.
In this article, we will show you how to install free Oracle OpenJDK 13 in RHEL 8/7/6, CentOS 8/7/6 and Fedora 30-31 to develop and run Java applications.
Installing Free Oracle OpenJDK 13 in CentOS/RHEL and Fedora
To install open-source Oracle OpenJDK 13, you need to download the production-ready OpenJDK 13 from the official page or run the following wget command to download and install it as shown.
# cd /opt # wget https://download.java.net/java/GA/jdk13/5b8a42f3905b406298b72d750b6919f6/33/GPL/openjdk-13_linux-x64_bin.tar.gz # tar -xvf openjdk-13_linux-x64_bin.tar.gz
To check the Java version, you have to use the full location to the binary as shown.
# /opt/jdk-13/bin/java -version
Sample Output
openjdk version "13" 2019-09-17 OpenJDK Runtime Environment (build 13+33) OpenJDK 64-Bit Server VM (build 13+33, mixed mode, sharing)
Setup Java Environment Variables
Next, insert Java environment variables and the executable files path into your system $PATH variable, by issuing the below commands. This method ensures that Java environment variables and executables will be accessible system-wide.
# export JAVA_HOME=/opt/jdk-13/ # export PATH=$PATH:/opt/jdk-13/bin
The above JAVA_HOME environment variable sets the directory where Java is installed on your server.
You can also define it in the /etc/environment global shell start-up file as shown.
# vi /etc/environment
Then add the following lines in the file.
# export JAVA_HOME=/opt/jdk-13/ # export PATH=$PATH:/opt/jdk-13/bin
Save the file and close it. Then source it as follows.
# source /etc/environment
And now if you check the JAVA_HOME environment variable and Java version, it should point to the Java installation directory and default version that you want to use.
# echo $JAVA_HOME # java -version
Congratulations! You’ve successfully installed the latest version of Oracle OpenJDK 13 in RHEL 8/7/6, CentOS 8/7/6 and Fedora 30-31 to develop and run Java applications.
Hi,
I installed OpenJDK 13 the I did the global shell start-up file.
Added:
Then ran the following command to active it.
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.
Hi Ravi,
Great post, and really helpful.
I have put your techniques into use, it worked
Thanks for sharing!
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?
@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..
@Ravi Saive
Hi. I want to know if java 1.8 is supported on RHEL 5.11. Could you pls help?
@Hari,
I don’t think that latest Java version will support on older CentOS 5.11, why not upgrade to newer CentOS version?
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.
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.
@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.
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…
Do you have a documentation on how to install JavaFX on centos.