Skip to content

Instantly share code, notes, and snippets.

@branneman
Last active October 1, 2017 16:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save branneman/3d2658bf5586029878e47557e544b4b6 to your computer and use it in GitHub Desktop.
Save branneman/3d2658bf5586029878e47557e544b4b6 to your computer and use it in GitHub Desktop.
macOS: Manage Multiple versions of Java

macOS: Manage Multiple versions of Java

Setup tooling

brew update
brew install jenv
brew tap caskroom/cask
brew tap caskroom/versions
mkdir ~/.jenv/versions

# Already in: https://github.com/branneman/dotfiles/blob/f2002f4/.profile#L41-L42
echo 'export PATH="$HOME/.jenv/bin:$PATH"' >> ~/.profile
echo 'eval "$(jenv init -)"' >> ~/.profile

Restart your terminal when you're done.

Install Java versions

Download & Install all the different Java versions you like, then print all found Java versions:

/usr/libexec/java_home -V

Add them to jenv:

jenv add /Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
jenv add /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home

Print all installed versions

jenv versions

Switch version

jenv global oracle64-1.8.0.144
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment