Skip to content

Commit

Permalink
Dynamically set JAVA_HOME based on OS
Browse files Browse the repository at this point in the history
Set JAVA_HOME correctly on OS X Lion and Ubuntu 11.04.

Ubuntu 11.04 is currently my Linux of choice. If this logic proves to
not be portable to other Linuxes that I use in the future, then I'll
update the logic at that time.
  • Loading branch information
jasonrudolph committed Mar 9, 2012
1 parent db44a58 commit 5c3e02b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion bash/paths
@@ -1,4 +1,9 @@
export JAVA_HOME=$(/usr/libexec/java_home)
if [[ "$PLATFORM" == 'osx' ]]; then
export JAVA_HOME=$(/usr/libexec/java_home)
elif [[ "$PLATFORM" == 'linux' ]]; then
# Credit: http://serverfault.com/a/143838
export JAVA_HOME=$(readlink -f /usr/bin/java | sed "s:bin/java::")
fi

export PATH="~/bin:~/src/etc/scripts:/usr/local/bin:/usr/local/sbin:$PATH"
export MANPATH="/usr/local/man:/usr/local/mysql/man:/usr/local/git/man:$MANPATH"
Expand Down
2 changes: 2 additions & 0 deletions bashrc
Expand Up @@ -2,6 +2,8 @@ PLATFORM='unknown'
unamestr=`uname`
if [[ "$unamestr" == 'Darwin' ]]; then
PLATFORM='osx'
elif [[ "$unamestr" == 'Linux' ]]; then
PLATFORM='linux'
fi

source ~/.bash/aliases
Expand Down

0 comments on commit 5c3e02b

Please sign in to comment.