Last active
October 18, 2016 03:01
-
-
Save oliverdowling/981a0855c39aa8426040 to your computer and use it in GitHub Desktop.
Install Oracle's JRE on Mac OS X
This file contains 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 | |
# DISCLAIMER! Although this file *could* be executed, I recommend against running this whole file. | |
# This is because I have not added any error checking | |
# If, for example, you did not download the correct JRE file to your Downloads folder, or saved it elsewhere, this will likely move your home directory | |
# If you have ignored that and just want to run the file anyway (it's faster, after all) you'll need to do this in Terminal: | |
#cd ~/Downloads/ | |
#chmod +x install-jre-macosx-x64.sh | |
#sudo ./install-jre-macosx-x64.sh | |
# Make sure to download the latest JRE from here: http://www.oracle.com/technetwork/java/javase/downloads/index.html | |
# You should end up with a file in your Downloads folder named something similar to jre-8u60-macosx-x64.tar.gz | |
# Go to the download and unpack it | |
cd ~/Downloads | |
tar -xzf `ls -1 jre-8u*-macosx-x64.tar.gz | sort -rn -t u -k 2 | head -1` | |
# Now move to this newly created directory | |
cd `ls -1d jre1.8.*.jre/ | sort -rn -t _ -k 1.8 -k 2 | head -1` | |
# **If you just received an error message on any of the previous commands, do not continue!** | |
# Edit the Info.plist so that it is usable from the command line and to open Java applications | |
defaults write `pwd`/Contents/Info.plist JavaVM -dict-add 'JVMCapabilities' '<array><string>JNI</string><string>BundledApp</string><string>CommandLine</string></array>' | |
# Fix a permissions issue created by using `defaults write` | |
chmod 0644 Contents/Info.plist | |
# The previous command converted the Info.plist file to a binary format, which is okay, but it is not as user friendly, so lets change it back | |
plutil -convert xml1 `pwd`/Contents/Info.plist | |
# Now we need to move it to the Java Virtual Machines folder. This requires sudo privileges | |
sudo mv `pwd` /Library/Java/JavaVirtualMachines/ | |
# Create some folders and links for backwards compatibility that some applications require | |
mkdir -p Contents/Home/bundle/Libraries | |
cd Contents/Home/bundle/Libraries | |
ln -s ../../lib/server/libjvm.dylib libserver.dylib | |
# If you just ran this, and your home directory is now in /Library/Java/JavaVirtualMachines/ you can recover by moving it back with | |
#sudo mv /Library/Java/JavaVirtualMachines/<username> /Users/ | |
# Make sure to replace "<username>" with your username. You can double check the contents of the JavaVirtualMachines folder with: | |
#ls /Library/Java/JavaVirtualMachines/ | |
# Some people like to use JAVA_HOME environment variable, but general users do not require it | |
# If you need it for whatever reason, uncomment the following lines | |
#echo export JAVA_HOME=`/usr/libexec/java_home` >> ~/.bash_profile | |
#chmod u+x ~/.bash_profile | |
# Some troublesome apps still wont work, and require being tricked into thinking Java 6 is installed. | |
# As of El Capitan, this is much harder to do, because it prevents System files from being modified by the user with System Integrity Protection (SIP) | |
# SIP can only be disabled by booting into recovery mode (hold Command+R on startup) the in Terminal (found in Utilities menu) | |
#csrutil disable | |
# Reboot your computer so that you are no longer in Recovery Mode | |
#sudo mkdir -p /System/Library/Java/JavaVirtualMachines/1.6.0.jdk | |
#sudo mkdir -p /System/Library/Java/Support/Deploy.bundle | |
# Reboot into Recovery Mode (again) and enable SIP again | |
#csrutil enable | |
# Reboot (yes, again) and you should be good to go. | |
# Not all applications will work with the latest Java. It may be that you just have to install legacy Java 6 runtime. | |
# This can be found here: https://support.apple.com/kb/DL1572?locale=en_US |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment