Last active
February 14, 2016 19:30
-
-
Save ianblenke/4287cfb29668cacdbc96 to your computer and use it in GitHub Desktop.
Scripted install of Java on Mac
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
which brew || /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" | |
brew tap caskroom/cask | |
# Install java | |
brew cask install java | |
# Install ant, and the Android NDK and SDK | |
brew install ant android-ndk android-sdk | |
# Java 1.6 - Only use this for projects that need a very old java | |
wget -O /tmp/javaforosx.dmg http://support.apple.com/downloads/DL1572/en_US/javaforosx.dmg | |
hdiutil mount /tmp/javaforosx.dmg | |
cp -a /Volumes/Java\ for\ OS\ X\ 2015-001/JavaForOSX.pkg /tmp | |
hdiutil unmount /Volumes/Java\ for\ OS\ X\ 2015-001/ | |
sudo installer -pkg /tmp/JavaForOSX.pkg -target / | |
rm -f /tmp/JavaForOSX.pkg | |
# List the Java versions installed | |
/usr/libexec/java_home -V | |
# Use the latest java at the top of the list | |
export JAVA_HOME="$(/usr/libexec/java_home -v $(/usr/libexec/java_home -V 2>&1 | grep jdk | cut -d, -f1 | head -1))" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment