Created
August 5, 2015 16:52
-
-
Save ke4roh/10e19a205c4a5a07d280 to your computer and use it in GitHub Desktop.
Where is 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 | |
function whereIsFile() { | |
pushd . > /dev/null | |
FILE_PATH=$1; | |
while([ -h "${FILE_PATH}" ]) do cd -P $(dirname "${FILE_PATH}"); FILE_PATH=$(readlink "${FILE_PATH}"); done | |
cd -P $(dirname "${FILE_PATH}") > /dev/null | |
echo $(pwd) | |
popd >/dev/null | |
} | |
JAVA_HOME=$(dirname $(dirname $(whereIsFile $(which java)))) | |
echo $JAVA_HOME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment