Skip to content

Instantly share code, notes, and snippets.

@danieldietrich danieldietrich/README.md
Last active Jan 19, 2019

Embed
What would you like to do?
Howto install a new JDK on a Mac

Howto install a new JDK on a Mac

  1. Download JDK: http://jdk.java.net/13/ to ~/Downloads
  2. Unpack downloaded .tar.gz bundle
  3. Goto base dir cd /Library/Java/JavaVirtualMachines
  4. Move unpacked JDK mv ~/Downloads/jdk-13.jdk .
  5. Change owner sudo chown -R root jdk-13.jdk/
  6. Change group sudo chgrp -R wheel jdk-13.jdk/
  7. Remove quarantaine flag sudo xattr -dr com.apple.quarantine jdk-13.jdk
  8. Create symlink sudo ln -s jdk-13.jdk/ jdk13

I use the following helper in ~/.bash_profile to switch JDKs:

# -----------------------------------------------------------------------------
#  JDK SWITCHER ...
#  Usage: jdk <version>
# -----------------------------------------------------------------------------

# !! ENSURE NO PATH CHANGES ARE MADE WITHIN THIS SCRIPT BELOW THIS LINE !!
export __BACKUP_PATH=$PATH

function jdk() {
  export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk$1/Contents/Home"
  export PATH=$JAVA_HOME/bin:$__BACKUP_PATH
}

# set default jdk
jdk 11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.