-
-
Save marnovo/e9e0e8989a3228d6c9ddda82768f934a to your computer and use it in GitHub Desktop.
Revisions
-
trmaphi revised this gist
Apr 13, 2019 . No changes.There are no files selected for viewing
-
trmaphi revised this gist
Apr 8, 2019 . 1 changed file with 7 additions and 4 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -3,8 +3,6 @@ JDKS_DIR="/Library/Java/JavaVirtualMachines" JDKS=( $(ls ${JDKS_DIR}) ) JDKS_STATES=() # Map state of JDK for (( i = 0; i < ${#JDKS[@]}; i++ )); do @@ -16,8 +14,12 @@ for (( i = 0; i < ${#JDKS[@]}; i++ )); do echo "${i} ${JDKS[$i]} ${JDKS_STATES[$i]}" done # Declare variables DEFAULT_JDK_DIR="" DEFAULT_JDK="" OPTION="" # OPTION for default jdk and set variables while [[ ! "$OPTION" =~ ^[0-9]+$ || OPTION -ge "${#JDKS[@]}" ]]; do read -p "Enter Default JDK: " OPTION if [[ ! "$OPTION" =~ ^[0-9]+$ ]]; then @@ -28,6 +30,7 @@ while [[ ! "$OPTION" =~ ^[0-9]+$ || OPTION -ge "${#JDKS[@]}" ]]; do echo "Out of index" fi done DEFAULT_JDK_DIR="${JDKS_DIR}/${JDKS[$OPTION]}" DEFAULT_JDK="${JDKS[$OPTION]}" @@ -38,7 +41,7 @@ for (( i = 0; i < ${#JDKS[@]}; i++ )); do fi done # Enable default jdk if [[ -f "${DEFAULT_JDK_DIR}/Contents/Info.plist.disable" ]]; then sudo mv "${DEFAULT_JDK_DIR}/Contents/Info.plist.disable" "${DEFAULT_JDK_DIR}/Contents/Info.plist" echo "Enable ${DEFAULT_JDK} as default JDK" -
trmaphi created this gist
Apr 7, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ #!/usr/bin/env bash JDKS_DIR="/Library/Java/JavaVirtualMachines" JDKS=( $(ls ${JDKS_DIR}) ) JDKS_STATES=() DEFAULT_JDK_DIR="" DEFAULT_JDK="" # Map state of JDK for (( i = 0; i < ${#JDKS[@]}; i++ )); do if [[ -f "${JDKS_DIR}/${JDKS[$i]}/Contents/Info.plist" ]]; then JDKS_STATES[${i}]=enable else JDKS_STATES[${i}]=disable fi echo "${i} ${JDKS[$i]} ${JDKS_STATES[$i]}" done # OPTION for default jdk and set variables OPTION="" while [[ ! "$OPTION" =~ ^[0-9]+$ || OPTION -ge "${#JDKS[@]}" ]]; do read -p "Enter Default JDK: " OPTION if [[ ! "$OPTION" =~ ^[0-9]+$ ]]; then echo "Sorry integers only" fi if [[ OPTION -ge "${#JDKS[@]}" ]]; then echo "Out of index" fi done DEFAULT_JDK_DIR="${JDKS_DIR}/${JDKS[$OPTION]}" DEFAULT_JDK="${JDKS[$OPTION]}" # Disable all jdk for (( i = 0; i < ${#JDKS[@]}; i++ )); do if [[ -f "${JDKS_DIR}/${JDKS[$i]}/Contents/Info.plist" ]]; then sudo mv "${JDKS_DIR}/${JDKS[$i]}/Contents/Info.plist" "${JDKS_DIR}/${JDKS[$i]}/Contents/Info.plist.disable" fi done #Enable default jdk if [[ -f "${DEFAULT_JDK_DIR}/Contents/Info.plist.disable" ]]; then sudo mv "${DEFAULT_JDK_DIR}/Contents/Info.plist.disable" "${DEFAULT_JDK_DIR}/Contents/Info.plist" echo "Enable ${DEFAULT_JDK} as default JDK" fi