Created
February 11, 2018 19:12
-
-
Save downspot/def43fb39610c184761b2bd8984604b1 to your computer and use it in GitHub Desktop.
Ubuntu find java home
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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