Jabba use does not alter environment on macOS
See below for command line session; this is on macOS Mojave 10.14.5 with AdoptOpenJDK 8 and 11, openj9 variants:
$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b03)
Eclipse OpenJ9 VM (build openj9-0.14.0, JRE 1.8.0 Mac OS X amd64-64-Bit 20190417_48 (JIT enabled, AOT enabled)
OpenJ9 - bad1d4d06
OMR - 4a4278e6
JCL - 5590c4f818 based on jdk8u212-b03)
$ jabba --version
0.11.2
$ jabba link system@8 /Library/Java/JavaVirtualMachines/jdk8u212-b03
$ jabba link system@11 /Library/Java/JavaVirtualMachines/jdk-11.0.3+7
$ jabba use system@11
$ java -version
openjdk version "1.8.0_212"
OpenJDK Runtime Environment (build 1.8.0_212-b03)
Eclipse OpenJ9 VM (build openj9-0.14.0, JRE 1.8.0 Mac OS X amd64-64-Bit 20190417_48 (JIT enabled, AOT enabled)
OpenJ9 - bad1d4d06
OMR - 4a4278e6
JCL - 5590c4f818 based on jdk8u212-b03)
I.e, java version does not change, I expect the second invocation of java -version to come from the JDK represented by system@11.
Same problem here.
If you installed Jabba through homebrew, that's could be the issue, the install method listed on github (wget piped into bash) works correctly and sets up some shell integrations, but the homebrew install does not :( (see also https://github.com/shyiko/jabba/issues/138)
Fyi, I did not install through homebrew but using wget.
I uninstalled homebrew version and installed using the official wget method. That fixed the issue and now jabbba updates my local path to the desired java binary.
:/ Not in a habit of doing curl | bash very often. Might be good to publish what extra setup the script does
I wound up just adding the following to my .zshrc until this is resolved:
JABBA_HOME=$HOME/.jabba
JABBA_HOME_TO_EXPORT=\$HOME/.jabba
_jabba() {
local fd3=$(mktemp /tmp/jabba-fd3.XXXXXX)
(JABBA_SHELL_INTEGRATION=ON `which jabba` "$@" 3>| ${fd3})
local exit_code=$?
eval $(cat ${fd3})
rm -f ${fd3}
return ${exit_code}
}
if [ ! -z "$(_jabba alias default)" ]; then
_jabba use default
fi
This is just a slight modification of what's done in the install script: https://github.com/shyiko/jabba/blob/master/install.sh#L134