El Capitan has been released, and because my previous Java post got a lot more traffic than I expected, I’ve decided to consolidate all the information from it and create a guide for installing just the JRE (Java Runtime Environment).
In case you want clearer instructions for the JDK, I have also created another post for installing the JDK if that’s what you require. Installing the JDK is actually simpler because Oracle includes an installer which does a few of the steps for you, so some people may actually prefer those instructions.
The instructions below should also work for future updates to the JRE, so no need to worry about having to find and update version numbers in the code for an update this time!
- Go to the Oracle Java downloads page and download the JRE
.tar.gzversion. This is important, because the
.dmginstaller does not work as you might expect. You should end up with a file named something similar to
jre-8u60-macosx-x64.tar.gz, but perhaps a newer version.
- Go to your Downloads folder and unzip the JRE download:
cd ~/Downloads tar -xzf `ls -1 jre-8u*-macosx-x64.tar.gz | sort -rn -t u -k 2 | head -1` cd `ls -1d jre1.8.*.jre/ | sort -rn -t _ -k 1.8 -k 2 | head -1`
If this failed for some reason, you can alternatively open the downloaded
Finderthen navigate to the unzipped directory in
- Edit the
Info.plistfile within to enable the JRE to be used from the the command line, and from bundled applications:
defaults write `pwd`/Contents/Info.plist JavaVM -dict-add 'JVMCapabilities' '<array><string>JNI</string><string>BundledApp</string><string>CommandLine</string></array>' chmod 0664 Contents/Info.plist plutil -convert xml1 Contents/Info.plist
The second line fixes a permissions issue create by using
defaults write. The third line is not required, but makes the file more user-friendly if you open it again in a text editor.
- Move the JRE folder to the correct location:
sudo mv `pwd` /Library/Java/JavaVirtualMachines/
Your password is required here because it is outside of your user folder. Be sure you are in the correct directory (the JRE folder) when you issue this command, because it will move your current directory to
- Create a link to add backwards compatibility for some applications made for older Java versions:
mkdir -p Contents/Home/bundle/Libraries cd Contents/Home/bundle/Libraries ln -s ../../lib/server/libjvm.dylib libserver.dylib
You should be done now, so try and open the application. If it does not work, some applications require legacy Java 6 to be installed. You can have it installed without actually using it, however, it’s possible to trick the applications into thinking legacy Java 6 is installed, without actually doing so.
If you’re running El Capitan, this is actually a little difficult now, because Apple added SIP (System Integrity Protection) to OS X. I have written a post explaining how to disable and enable SIP.
If you’ve disabled SIP, or are not running El Capitan yet, you can trick some applications into thinking legacy Java 6 is installed by creating two folders with the following commands in
sudo mkdir -p /System/Library/Java/JavaVirtualMachines/1.6.0.jdk sudo mkdir -p /System/Library/Java/Support/Deploy.bundle
Don’t forget to enable SIP again after creating these directories.