Notes to Self

Alex Sokolsky's Notes on Computers and Programming

Install Java on Mac

You should have brew installed.

  1. Install OpenJDK:
brew tap AdoptOpenJDK/openjdk
brew install --cask adoptopenjdk8
  1. Install jenv:
brew install jenv
  1. Add the installed Java to jenv:
jenv add /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home
jenv global 1.8
  1. Update your .zshrc
# set up jenv
export PATH="$HOME/.jenv/bin:$PATH"
eval "$(jenv init -)"

# From
export JAVA_HOME="$HOME/.jenv/versions/`jenv version-name`"
alias jenv_set_java_home='export JAVA_HOME="$HOME/.jenv/versions/`jenv version-name`"'

# call function on boot to set the JAVA_HOME var on every terminal startup

You should be good to go:

java -version

Fine tune your Java VM install.