Created
February 5, 2018 21:23
-
-
Save erikdw/100dbf4e00e69554de1a62ca2a650b1f to your computer and use it in GitHub Desktop.
setjdk shell function. This is what I've used in zsh, should work in bash too.
This file contains hidden or 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
# Example usage: setjdk 1.8 | |
function setjdk { | |
local ver=${1?Usage: setjdk <version>} | |
export JAVA_HOME=$(/usr/libexec/java_home -v $ver) | |
PATH=$(echo $PATH | tr ':' '\n' | grep -v Java | tr '\n' ':') | |
export PATH=$JAVA_HOME/bin:$PATH | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment