Skip to content

Instantly share code, notes, and snippets.

@greenstevester
Last active April 22, 2019 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save greenstevester/740b562bcc7910656b4e0465a84fdb0a to your computer and use it in GitHub Desktop.
Save greenstevester/740b562bcc7910656b4e0465a84fdb0a to your computer and use it in GitHub Desktop.
Uninstall Oracle Java on Mac OSX using the Terminal / Install AdoptOpenJDK using homebrew
Remove Java from the Apple System Preferences Pane
----------------------------------------------------
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -fr ~/Library/Application\ Support/Oracle/Java
Install with Homebrew
---------------------
install Homebrew if you haven't already. Make sure it is updated:
brew update
brew tap homebrew/cask-versions
brew search java
brew cask info java
Install a specific version of the JDK such as java8, java9, java10, java11, java12, or just java for the current:
brew cask install java
The AdoptOpenJDK version is available as well now from Homebrew Cask:
brew cask install adoptopenjdk
Will be installed into /Library/Java/JavaVirtualMachines/ which is the traditional location expected on Mac OSX.
update your .bash_profile
--------------------------
export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8)
export JAVA_12_HOME=$(/usr/libexec/java_home -v12)
alias java8='export JAVA_HOME=$JAVA_8_HOME'
alias java12='export JAVA_HOME=$JAVA_12_HOME'
export JAVA_HOME=$JAVA_12_HOME
reload bash or start a new terminal session
-------------------------------------------
source ~/.bash_profile
verify the new version
----------------------
which java && java -version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment