Created
March 19, 2022 16:50
-
-
Save sryze/8148f04366557abbc1efde5bb6ff842b to your computer and use it in GitHub Desktop.
Script for switching between different versions of Java on Windows (needs Git Bash or similar shell)
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/sh | |
java_version=$1 | |
java_home= | |
IFS=$'\n' | |
for d in $(find "/c/Program Files/Java" -name "jdk*$java_version*" -type d); do | |
java_home="$d" | |
done | |
if [ -z "$java_home" ]; then | |
echo "Could not find Java version $java_version" | |
else | |
export JAVA_HOME="$java_home" | |
export PATH="$java_home/bin:$PATH" | |
echo "Activated Java version $java_version ($java_home)" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: