Created
October 17, 2016 06:29
-
-
Save iv-m/04b5045be3c9ed943e3c708caf332624 to your computer and use it in GitHub Desktop.
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
# Select which JDK to use | |
# Usage example: | |
# $ . use_java 1.8 | |
JDK_DIR="$HOME/opt/jdk" | |
JDK_NAME=$(ls "$JDK_DIR" | grep "${1:-}" | tail -n1) | |
export JAVA_HOME="$JDK_DIR/$JDK_NAME" | |
export PATH="$JAVA_HOME/bin:$(awk -v RS=: -v ORS=: '/jdk/ {next} {print}' <<< "$PATH" | sed 's/:*$//g')" | |
echo "Selected JDK at $JAVA_HOME" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment