Skip to content

Instantly share code, notes, and snippets.

@lhazlewood
Last active November 2, 2018 19:44
Show Gist options
  • Save lhazlewood/39a2933d5193b17516df2ecc2a29247d to your computer and use it in GitHub Desktop.
Save lhazlewood/39a2933d5193b17516df2ecc2a29247d to your computer and use it in GitHub Desktop.
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}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment