Skip to content

Instantly share code, notes, and snippets.

@tridungpham
Forked from tommysdk/select_java_version
Created December 4, 2023 08:17
Show Gist options
  • Save tridungpham/9af34ee43f422fbe214e06765f5abf94 to your computer and use it in GitHub Desktop.
Save tridungpham/9af34ee43f422fbe214e06765f5abf94 to your computer and use it in GitHub Desktop.
Change default Java version on Mac OS X using Fish shell
# Based on https://stackoverflow.com/a/26252993/1665539
# Or this https://superuser.com/questions/1401673/how-to-set-a-specific-version-of-java-as-java-home-in-fish-in-macos
# Show all installed Java versions
/usr/libexec/java_home -V
# Select major version (if unique, otherwise specify full name e.g. 1.8.0_131)
set -x JAVA_HOME (/usr/libexec/java_home -v 1.8)
# Verify
java -version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment