🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to install java on centos and rocky linux
How to Install Java on CentOS and Rocky Linux
December 16, 2025 - 2. Select the desired Java SE version on the webpage and click the download link for the RPM package. 3. After the download is complete, install the package with the command below: sudo yum localinstall [path]/jre-[version]-linux-x64.rpm
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-install-java-on-centos-and-fedora
How To Install Java on CentOS, Rocky Linux, RHEL, and Fedora | DigitalOcean
March 18, 2022 - sudo wget --no-cookies ... my path. Please add instructions for setting environment variables and putting it into the path. $ sudo yum install java-1.7.0-openjdk [ ......
Discussions

How to install Java SDK on CentOS? - Stack Overflow
I have CentOS 5, but I don't know the steps to install Java SDK on Linux. Where to download the RPM file and what can I do next to fully install that? Then I need to install Tomcat. Or is there ... More on stackoverflow.com
🌐 stackoverflow.com
How can I instruct yum to install a specifc version of OpenJDK - Unix & Linux Stack Exchange
I'm trying to install 1:1.7.0.65-2.5.1.2.el6_5 version of OpenJDK by following this stackexchange answer, but I'm not able to specify the exact version number like yum install java-1.7.0-openjdk-d... More on unix.stackexchange.com
🌐 unix.stackexchange.com
java - Installing OpenJDK 11 on CentOS using yum - Stack Overflow
I want to install OpenJDK 11 using yum. However when I check the OpenJDK manual, it says you can use yum to install only up to Java 8. However, for Java 9 onwards it says that you have to download ... More on stackoverflow.com
🌐 stackoverflow.com
java - How to install Jdk in centos - Stack Overflow
You may already have a Java 5 installed ... command yum remove java ... finally I have intalled the oracle java and glassfish is also doing fine on it .. will look forward to try open jdk as well @Destroyica thank you for remove command should have tried it earlier stuck me for long 2014-08-15T15:40:32.36Z+00:00 ... mine refused to install (saying it already was) until I did rpm -e jdk prior to trying again if that helps anyone 2014-12-09T06:23:... More on stackoverflow.com
🌐 stackoverflow.com
🌐
DevOpsSchool.com
devopsschool.com › blog › complete-guide-of-java-installation-in-linux
Java Installation Guide in Linux & Windows -
Home Linux Java Installation Guide in Linux & Windows · Linux Rajesh Kumar · August 22, 2025 · 1 Comment ... $ su -c "yum install java-1.7.0-openjdk" # JRE Version $ su -c "yum install java-1.7.0-openjdk-devel" # JDK versionCode language: PHP (php)
🌐
Kifarunix
kifarunix.com › home › howtos › install oracle java 12 on centos 7/fedora 29
Install Oracle Java 12 on CentOS 7/Fedora 29 - kifarunix.com
March 11, 2024 - In this guide, we are going to learn how install Oracle Java 12 on CentOS 7/Fedora 29. For the installation of Oracle Java 12 on Ubuntu 18.04/Debian 9.8
🌐
LinuxVox
linuxvox.com › blog › install-java-runtime-linux
Install Java Runtime on Linux: A Comprehensive Guide — linuxvox.com
On CentOS and Fedora systems, you can use the yum or dnf package manager to install the OpenJDK JRE or JDK. ... If you prefer to install a specific version of Java or use the Oracle JDK, you can perform a manual installation.
🌐
javaspring
javaspring.net › blog › yum-install-java
A Comprehensive Guide to `yum install java` — javaspring.net
It resolves dependencies automatically, which means that when you install a package, yum will also install all the necessary packages that the target package depends on. Java is a high-level, class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible.
🌐
Linuxize
linuxize.com › home › java › how to install java on centos 7
How to Install Java on CentOS 7 | Linuxize
February 24, 2020 - At the time of writing, OpenJDK 11 is the current LTS version of Java and the recommended version to install. You can install it using yum by typing the following command:
Find elsewhere
🌐
InMotion Hosting
inmotionhosting.com › inmotion hosting home › support › product guides › vps hosting › how to install java on centos
How to Install Java on CentOS | InMotion Hosting
January 4, 2024 - The installation process consists of installing OpenJDK, the open source Java implementation which includes Font Renderer, or proprietary Oracle JRE/JDK with Flight Recorder which builds on top of OpenJDK. We recommend OpenJDK for the latest features. You may prefer Oracle JRE/JDK for stability. ... Install the latest version. As of January 25, 2021: ... You may see the following command afterward: There are unfinished transactions remaining. You might consider running yum-complete-transaction, or "yum-complete-transaction --cleanup-only" and "yum history redo last", first to finish them.
🌐
OpenJDK
openjdk.org › install
OpenJDK: Download and install
The openjdk-7-jre package contains just the Java Runtime Environment. If you want to develop Java programs then install the openjdk-7-jdk package. On the command line, type: $ su -c "yum install java-1.7.0-openjdk" The java-1.7.0-openjdk package contains just the Java Runtime Environment.
🌐
Medium
medium.com › @minaxijoshi3101 › install-java-on-centos-and-set-java-home-using-the-yum-repo-8696fea58266
Install JAVA on Centos and windows. Also, set JAVA_HOME using the YUM repo | by DevOpsLab-LiveScenarios | Medium
September 29, 2024 - Install JAVA on Centos and windows. Also, set JAVA_HOME using the YUM repo Steps: Check Centos Version: cat /etc/redhat-release or cat /etc/os-release Update the System: sudo yum update 2. Check …
🌐
IBM
ibm.com › docs › en › qradar-common
Installing Java on RHEL or CentOS Linux - IBM Documentation
December 1, 2025 - To install Java on your RHEL or ... the correct version number for the installable package and run the following command. yum -y install ibm-semeru-certified-11-jdk-11.<version>.x86_64.rpm...
🌐
Gluster
gluster.org › setting-up-a-javamaven-on-rhelfedora-2
Gluster » Setting up a Java+Maven on RHEL/Fedora
To install java on Fedora (openjdk) jvyas> sudo yum list *java* | grep open | grep devel #<– sanity check to see what JDKs are available.
Top answer
1 of 1
3

To answer your question I'll show you what I'd do in order to install/upgrade java.

To see the current version of java installed I'd run:

java -version

To see the name of the java package which is currently installed, I'd run:

yum list installed | grep java

to install an openjdk java you'll have to run:

yum install java-1.8.0-openjdk.x86_64

As far as I know it is not possible to install java-1.8.0 just by running:

yum install java-1.8.0

as there are two versions of Java, one is the openjdk-java and the other is oracle-java.

So by supplying the -openjdk.x86.64 you actually tell yum which version of Java should be installed.

So the answer to your question "So how can I see what a package name will actually install? Or how can I search for package names instead?" is that you need to provide the exact name of the package you intend to install and that's the package which will be installed (along with it's dependancies).

In order to display files which a yum package contains, you can run the following command:

repoquery -l packagename

Example:

[root@centolel ~]# repoquery -l java-1.8.0-openjdk
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-1.b13.el6.x86_64/jre/bin/policytool
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-1.b13.el6.x86_64/jre/lib/amd64/libawt_xawt.so
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-1.b13.el6.x86_64/jre/lib/amd64/libjawt.so
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-1.b13.el6.x86_64/jre/lib/amd64/libjsoundalsa.so
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.121-1.b13.el6.x86_64/jre/lib/amd64/libsplashscreen.so
/usr/share/applications/java-1.8.0-openjdk-1.8.0.121-1.b13.el6.x86_64-policytool.desktop
/usr/share/icons/hicolor/16x16/apps/java-1.8.0.png
/usr/share/icons/hicolor/24x24/apps/java-1.8.0.png
/usr/share/icons/hicolor/32x32/apps/java-1.8.0.png
/usr/share/icons/hicolor/48x48/apps/java-1.8.0.png

How can you find the tomcat6 packages?

[root@centolel ~]# yum search tomcat6
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: centos.joinweb.co.il
 * epel: mirror.nonstop.co.il
 * extras: centos.joinweb.co.il
 * rpmforge: mirror1.hs-esslingen.de
 * updates: centos.joinweb.co.il
=========================================================================================== N/S Matched: tomcat6 ===========================================================================================
glite-security-trustmanager-tomcat6.noarch : Java trustmanager interface supporting a GSI grid name space
tomcat6.noarch : Apache Servlet/JSP Engine, RI for Servlet 2.5/JSP 2.1 API
tomcat6-admin-webapps.noarch : The host-manager and manager web applications for Apache Tomcat
tomcat6-docs-webapp.noarch : The docs web application for Apache Tomcat
tomcat6-el-2.1-api.noarch : Expression Language v1.0 API
tomcat6-javadoc.noarch : Javadoc generated documentation for Apache Tomcat
tomcat6-jsp-2.1-api.noarch : Apache Tomcat JSP API implementation classes
tomcat6-lib.noarch : Libraries needed to run the Tomcat Web container
tomcat6-servlet-2.5-api.noarch : Apache Tomcat Servlet API implementation classes
tomcat6-webapps.noarch : The ROOT and examples web applications for Apache Tomcat

Edit #1:

Okay, as I've tested it now it seems like I was wrong when I said you can't install using the yum install java-1.8.0, it works in my machine.

When I ran yum install java-1.8.0 on my test machine, it automatically suggested me the openjdk version so I guess it's the default one:

--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                                 Arch               Version                           Repository           Size
========================================================================================================================
Installing:
 java-1.8.0-openjdk                      x86_64             1:1.8.0.121-1.b13.el6             base                200 k
Installing for dependencies:
 java-1.8.0-openjdk-headless             x86_64             1:1.8.0.121-1.b13.el6             base                 32 M
 ttmkfdir                                x86_64             3.0.9-32.1.el6                    base                 43 k
 xorg-x11-fonts-Type1                    noarch             7.2-11.el6                        base                520 k

Another useful command is:

yum info java-1.8.0-openjdk.x86_64

I believe the answer you're looking for can be found here.

Top answer
1 of 2
27

As of November 2020

you can achieve this in 2 steps:

  1. Install Java 11 using yum:

    yum install java-11-openjdk-devel

  2. Get all the Java configurations available in your machine:

    alternatives --config java

    Run the above command, select the version you want to set, I've set 1 here:

    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.el7_8.x86_64/bin/java)
    *+ 2           java-1.8.0-openjdk.x86_64 (/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-0.el7_8.x86_64/jre/bin/java)
    
    Enter to keep the current selection[+], or type selection number: 1
    
  3. Check java -version:

    openjdk version "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)
    

Java 11 is now set to be used globally.

2 of 2
18

The reason, in short, is because someone has to maintain the packages and put these into the repositories your system is using and verify, that they run stable. For example, the OpenJDK 11 on Debian is still in buster (testing) and sid (unstable) and therefore not available in any stable branch. I guess in CentOS (I am not that familiar with it tbh.) it's the same situation.

Sooner or later you'll have to install software without a manager in any OS, so even if you're saying you're a noob, you'll have to learn that sooner or later. And if you want to use openjdk11 now, you'll have to use either an unofficial repository or install the software by hand, what I'd recommend.

However, here is a guide which is the second hit on Google for openjdk11 centos:

curl -O https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz
tar zxvf openjdk-11.0.1_linux-x64_bin.tar.gz
mv jdk-11.0.1 /usr/local/

vi /etc/profile.d/jdk11.sh

# create new
export JAVA_HOME=/usr/local/jdk-11.0.1
export PATH=$PATH:$JAVA_HOME/bin

source /etc/profile.d/jdk11.sh

java -version

openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment 18.9 (build 11.0.1+13)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.1+13, mixed mode)

Source: https://www.server-world.info/en/note?os=CentOS_7&p=jdk11&f=2

🌐
TecMint
tecmint.com › home › open source › how to install java 17 on rhel-based linux distributions
How to Install Java 14 on CentOS/RHEL 7/8 & Fedora
November 1, 2021 - # yum localinstall jdk-17_linux-x64_bin.rpm · Next, confirm the installed Java version. # java -version java version "17.0.1" 2021-10-19 LTS Java(TM) SE Runtime Environment (build 17.0.1+12-LTS-39) Java HotSpot(TM) 64-Bit Server VM (build 17.0.1+12-LTS-39, mixed mode, sharing) 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.
🌐
Red Hat
docs.redhat.com › en › documentation › red_hat_build_of_openjdk › 21 › html-single › installing_and_using_red_hat_build_of_openjdk_21_on_rhel › index
Installing and using Red Hat build of OpenJDK 21 on RHEL | Red Hat build of OpenJDK | 21 | Red Hat Documentation
Add the installonlypkgs option in the /etc/yum.conf directory to specify the Red Hat build of OpenJDK packages that yum can install but not update. installonlypkgs=java-<version>--openjdk,java-<version>--openjdk-headless,java-<version>--openjdk-devel
Top answer
1 of 4
64

There are JDK versions available from the base CentOS repositories. Depending on your version of CentOS, and the JDK you want to install, the following as root should give you what you want:

OpenJDK Runtime Environment (Java SE 6)

yum install java-1.6.0-openjdk

OpenJDK Runtime Environment (Java SE 7)

yum install java-1.7.0-openjdk

OpenJDK Development Environment (Java SE 7)

yum install java-1.7.0-openjdk-devel

OpenJDK Development Environment (Java SE 6)

yum install java-1.6.0-openjdk-devel

Update for Java 8

In CentOS 6.6 or later, Java 8 is available. Similar to 6 and 7 above, the packages are as follows:

OpenJDK Runtime Environment (Java SE 8)

yum install java-1.8.0-openjdk

OpenJDK Development Environment (Java SE 8)

yum install java-1.8.0-openjdk-devel

There's also a 'headless' JRE package that is the same as the above JRE, except it doesn't contain audio/video support. This can be used for a slightly more minimal installation:

OpenJDK Runtime Environment - Headless (Java SE 8)

yum install java-1.8.0-openjdk-headless
2 of 4
38

I advise you to use the same JDK as you may use with Windows: the Oracle one.

http://www.oracle.com/technetwork/java/javase/downloads/index.html
Go to the Java SE 7u67 section and click on JDK7 Download button on the right.

On the new page select the option "(¤) Accept License Agreement"
Then click on jdk-7u67-linux-x64.rpm

On your CentOS, as root, run:

$ rpm -Uvh jdk-7u67-linux-x64.rpm
$ alternatives --install /usr/bin/java java /usr/java/latest/bin/java 2

You may already have a Java 5 installed on your box... before installing the downloaded rpm remove previous Java by running this command yum remove java