Skip to content

Instantly share code, notes, and snippets.

@lhazlewood
Last active November 2, 2018 19:44
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
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}"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment