Installing an older version of Java on OSX using Homebrew
Nov 11, 2017
3 minute read
Homebrew is an extremely useful tool until it isn’t. Sometimes, it can hinder you.
For example, I was trying to install Bazel, which is required to run an image-captioning inference engine I was trying to run. Brew had some issues I needed to work through. Here is the story:
Bazel, as of right now, no longer supports Java 7 and below. It only supports Java 8. Great, that’s fine, I’ll just use brew cask install java like it told me to.
Let’s verify that we have the right versions of Java:
Then, I updated my ~/.zshrc to have this line:
Then, I ran source ~/.zshrc to ensure this change gets picked up and $JAVA_HOME gets set to my Java 9 installation.
Great! I just installed Java 9. Bazel should be happy now. Let’s try again:
This led me down a rabbithole of trying to install older versions of Java using Homebrew. Eventually, I found the right Caskroom command I needed to run:
Let’s verify again:
Once again, I needed to update my ~/.zshrc to ensure $JAVA_HOME is correct:
Then, of course, I had to run source ~/.zshrc again.
Finally, after all this time spent trying to get my toolchain working, I was able to run the bazel command I needed: