Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Find all existing JDK or JRE installations on RedHat, Centos or Fedora
# Specifically JDK installations (contain 'javac' command) and not JREs:
yum --disablerepo=* whatprovides '*/bin/javac' | grep ilename | awk -F': ' '{print $2}' | sed 's/\/bin\/javac//'
# All JRE installations (those with bin/java but without bin/javac). Includes JREs that are included in JDKs.
for candidate in $(yum --disablerepo=* whatprovides '*/bin/java' | grep ilename | awk -F': ' '{print $2}' | sed 's/\/bin\/java//'); do
if [ ! -x "${candidate}/bin/javac" ]; then
echo "${candidate}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment