Created
August 3, 2015 20:25
-
-
Save ekilah/0d8fbc6b1e3e3c3d2b1a to your computer and use it in GitHub Desktop.
Useful .bashrc snippet for setting the current JDK version on a Mac
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
# the below two functions are useful to set the current JDK. usage: `$ setjdk 1.6` | |
function setjdk() { | |
if [ $# -ne 0 ]; then | |
removeFromPath '/System/Library/Frameworks/JavaVM.framework/Home/bin' | |
if [ -n "${JAVA_HOME+x}" ]; then | |
removeFromPath $JAVA_HOME | |
fi | |
export JAVA_HOME=`/usr/libexec/java_home -v $@` | |
export JDK_HOME="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK" | |
export PATH=$JAVA_HOME/bin:$PATH | |
fi | |
} | |
function removeFromPath() { | |
export PATH=$(echo $PATH | sed -E -e "s;:$1;;" -e "s;$1:?;;") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment