From 6c1c0499edc505cc0a394f5c776e502a2607afa5 Mon Sep 17 00:00:00 2001 From: Holger Just Date: Tue, 12 Apr 2016 12:40:29 +0200 Subject: [PATCH] Add jhome helper to set the JAVA_HOME for a specific version in the environment --- .bashrc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.bashrc b/.bashrc index 7436673..05034f2 100644 --- a/.bashrc +++ b/.bashrc @@ -91,6 +91,17 @@ case `uname` in . "$(brew --prefix)/etc/bash_completion" fi + # Set the JAVA_HOME environment variable to the correct versob + jhome() { + if [ "$#" -ge 1 ]; then + export JAVA_HOME="$(/usr/libexec/java_home -v "$@")" + else + export JAVA_HOME="$(/usr/libexec/java_home)" + fi + echo "JAVA_HOME:" "$JAVA_HOME" + java -version + } + ;; Linux) PATH=$PATH:/var/lib/gems/1.8/bin:/var/lib/gems/1.9/bin