AdoptOpenJDK / homebrew-openjdk

AdoptOpenJDK HomeBrew Tap

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

java 8 doesn't seem to take precedence

xenoterracide opened this issue · comments

> brew cask reinstall adoptopenjdk8                                                                                                                                                                     ~
==> Downloading https://github.com/AdoptOpenJDK/openjdk8-binaries/releases/download/jdk8u252-b09.1/OpenJDK8U-jdk_x64_mac_hotspot_8u252b09.pkg
Already downloaded: /Users/calebcushing/Library/Caches/Homebrew/downloads/57a6643f7b6de270e63dfc545e0d665dc6de2c7081f7537ffba2ccdbdae46d2d--OpenJDK8U-jdk_x64_mac_hotspot_8u252b09.pkg
==> Verifying SHA-256 checksum for Cask 'adoptopenjdk8'.
==> Uninstalling Cask adoptopenjdk8
==> Uninstalling packages:
net.adoptopenjdk.8.jdk
Password:
Sorry, try again.
Password:
==> Purging files for version 8,252:b09.1 of Cask adoptopenjdk8
==> Installing Cask adoptopenjdk8
==> Running installer for adoptopenjdk8; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
installer: Package name is AdoptOpenJDK
installer: Upgrading at base path /
installer: The upgrade was successful.
package-id: net.adoptopenjdk.8.jdk
version: 1.8.0_252-b09
volume: /
location: Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk
install-time: 1588299930
🍺  adoptopenjdk8 was successfully installed!
> java -version                                                                                                                                                                                         ~
openjdk version "11.0.5" 2019-10-15
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.5+10, mixed mode)
> brew cask install adoptopenjdk14                                                                                                                                                                      ~
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 2 taps (homebrew/core and homebrew/cask).
==> Updated Formulae
angular-cli                                        flyway                                             scamper                                            vault

==> Downloading https://github.com/AdoptOpenJDK/openjdk14-binaries/releases/download/jdk-14.0.1%2B7/OpenJDK14U-jdk_x64_mac_hotspot_14.0.1_7.pkg
Already downloaded: /Users/calebcushing/Library/Caches/Homebrew/downloads/e236714a623c060a36cf5d09e3194d55ea718a969d84c7b72474af5b791095dd--OpenJDK14U-jdk_x64_mac_hotspot_14.0.1_7.pkg
==> Verifying SHA-256 checksum for Cask 'adoptopenjdk14'.
==> Installing Cask adoptopenjdk14
==> Running installer for adoptopenjdk14; your password may be necessary.
==> Package installers may write to any location; options such as --appdir are ignored.
installer: Package name is AdoptOpenJDK
installer: Upgrading at base path /
installer: The upgrade was successful.
package-id: net.adoptopenjdk.14.jdk
version: 14.0.1+7
volume: /
location: Library/Java/JavaVirtualMachines/adoptopenjdk-14.jdk
install-time: 1588300023
🍺  adoptopenjdk14 was successfully installed!
> java -version                                                                                                                                                                                         ~
openjdk version "14.0.1" 2020-04-14
OpenJDK Runtime Environment AdoptOpenJDK (build 14.0.1+7)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 14.0.1+7, mixed mode, sharing)

@xenoterracide What is the problem, specifically?

you can install 8, but then you can't immediately use it without further work, 11 is still used instead of 8.

@xenoterracide you have to swap your default Java after an install.

/usr/libexec/java_home -V will list them and there are a few ways you can swap (using shell scripting or the jenv tool). https://www.jenv.be/

Some background because I suspect that is what is causing the confusion: java_home is a macOS tool. It selects the java executable to use if you invoke java without specifying the full path to the executable. By default, it always selects the newest one, i.e., the one with the highest version number. Our installers merely install the JDK but do not configure the java_home tool. There is no default place to do so. We‘d need to hack around in .zshrc, .bashrc etc. Besides, users might get confused in the case of updates when suddenly another version becomes active because the update order changed in comparison to the install order.

My recommendation: Set JAVA_HOME explicitly as explained by our README.

closing, this is default macOS behaviour