1 min readMay 14, 2020
Just a note that for Macs, you don’t need to install `jenv` to manage Java versions. Just install the JDKs in the usual place: `/Library/Java/JavaVirtualMachines`. Then add these two very short functions. For bash:
# .bashrc
usejava() {
export JAVA_HOME=`/usr/libexec/java_home -v $1`
}alias jvms='/usr/libexec/java_home -V'
Or for fish:
# ~/.config/fish/function/usejava.fish
function usejava
set -x JAVA_HOME (/usr/libexec/java_home -v $argv[1])
end# ~/.conda/fish/config.fish
alias jvms '/usr/libexec/java_home -V'
Then in a terminal you can show which versions of java are available using jvms
and select one using just its version number like usejava 11
, usejava 1.8
or even usejava 1.8_222
if you need to get specific.