Skip to content

Instantly share code, notes, and snippets.

@downspot
Created February 11, 2018 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save downspot/def43fb39610c184761b2bd8984604b1 to your computer and use it in GitHub Desktop.
Save downspot/def43fb39610c184761b2bd8984604b1 to your computer and use it in GitHub Desktop.
Ubuntu find java home
#!/bin/bash
# Find the absolute path of the java executable
# follow all symlinks (to cover /etc/alternatives/java ...)
jpath=$(readlink -e $(which java))
if [[ "$jpath" != "" ]]; then
while [[ "$jpath" != "/" ]]; do
jpath=$(dirname $jpath)
tryinc="$jpath/include"
if [[ -d "$tryinc" ]]; then
echo $jpath
exit 0
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment