Finally Updating to AdoptOpenJDK for JDK 8 and JDK 11

java-logo-thumb.png

This morning I decided to really dig into the Homebrew support for AdoptOpenJDK - and while I was initially a little unsure of the AdoptOpenJDK group, after reading their web site, and digging into their Homebrew cask, I was convinced to give it a try. It will keep things moving with updates on the JDKs - delivering JDK 1.8.0r212 as of today, and that's what my biggest fear was. So let's get to it.

In order to get the very latest AdoptOpenJDK (11), it was as simple as:

  $ brew cask install adoptopenjdk

which resulted in my installation directory looking like:

  $ ls /Library/Java/JavaVirtualMachines/
  1.6.0_26-b03-383.jdk/    jdk1.7.0_45.jdk/         jdk1.8.0_144.jdk/
  adoptopenjdk-11.0.2.jdk/ jdk1.7.0_51.jdk/         jdk1.8.0_181.jdk/
  jdk-10.0.2.jdk/          jdk1.7.0_75.jdk/         jdk1.8.0_40.jdk/
  jdk1.7.0_13.jdk/         jdk1.8.0_131.jdk/        openjdk-11.0.2.jdk/

At this point, I could remove the openjdk-11.0.2.jdk/ install, as that's from Oracle, proper, and I really just want to let that go due to the licensing...

  $ brew cask uninstall java

and then re-select the correct JDK 11 with:

  $ setjdk 11; echo $JAVA_HOME
  /Library/Java/JavaVirtualMachines/adoptopenjdk-11.0.2.jdk/Contents/Home

So it was installed properly, and picked up the new installation from AdoptOpenJDK. Good. Now in order to pick up the older versions, we can follow the instructions on the Homebrew cask:

  $ brew tap AdoptOpenJDK/openjdk
  $ brew cask install adoptopenjdk8

and after this, we have the following installed on my machine:

  $ ls
  1.6.0_26-b03-383.jdk/    jdk1.7.0_13.jdk/         jdk1.8.0_131.jdk/
  adoptopenjdk-11.0.2.jdk/ jdk1.7.0_45.jdk/         jdk1.8.0_144.jdk/
  adoptopenjdk-8.jdk/      jdk1.7.0_51.jdk/         jdk1.8.0_181.jdk/
  jdk-10.0.2.jdk/          jdk1.7.0_75.jdk/         jdk1.8.0_40.jdk/

and I have to admit, I'm a little concerned about the lack of a release number on the AdoptOpenJDK 8's directory - but maybe that will be handled a little differently as they version them. We will have to wait and see.

At this point, we can:

  $ setjdk 1.8; echo $JAVA_HOME
  /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
  $ java -version
  openjdk version "1.8.0_212"
  OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_212-b03)
  OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.212-b03, mixed mode)

To make sure that we don't cleanup the old versions with Homebrew, when I install a new one, I added the following to my ~/.bashrc:

  export HOMEBREW_NO_INSTALL_CLEANUP=1

Which Homebrew says will keep from doing the automatic cleanups on the installs.

To do a final check with the AdoptOpenJDK 1.8.0r212, I checked what Leiningen was saying:

  $ lein --version
  Leiningen 2.8.3 on Java 1.8.0_212 OpenJDK 64-Bit Server VM

At this point, I've got AdoptOpenJDK 1.8.0r212, and 11.0.2, and updating each is very simple with brew. I just need to:

  $ brew update
  $ brew cask upgrade adoptopenjdk
  $ brew cask upgrade adoptopenjdk8

and then when I want, I can clean up the older versions with:

  $ brew update
  $ brew cleanup adoptopenjdk
  $ brew cleanup adoptopenjdk8

This is so much cleaner, and I don't have to worry about the crazy licensing from Oracle. It's a lot nicer place to be.