Last active
December 19, 2015 04:39
-
-
Save ruudud/5899133 to your computer and use it in GitHub Desktop.
Script to change Java JDK in OSX. Only tested on Mountain Lion, other versions should use the Java Preferences app.
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
#!/bin/bash | |
TXTBLD=$(tput bold) | |
TXTRST=$(tput sgr0) | |
JVMS="/System/Library/Java/JavaVirtualMachines" | |
JAVA7="jdk1.7.0_17.jdk" | |
JDKS="~/.jdks" | |
usage () { | |
echo "Usage: `basename $0` {6|7}" 1>&2 | |
echo -e "\n" | |
echo "$TXTBOLD Warning: $TXTRST Expects JDK1.7 to be found in $JDKS/$JAVA7" | |
echo -e "\n" | |
exit 0 | |
} | |
if [ $# -lt 1 ] | |
then | |
usage | |
fi | |
case "$1" in | |
6) echo "Setting Java to version 6…" | |
sudo rm -rf "$JVMS/$JAVA7" | |
exit $? | |
;; | |
7) echo "Setting Java to version 7…" | |
sudo cp -r $JDKS/$JAVA7 $JVMS | |
exit $? | |
;; | |
*) usage | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment