Java SE 8 on Mac OS X

I tried running an app that requires Java, but received an alert saying “you need a Java SE 6 runtime. Would you like to install one now?”

I did not want to install an old version of Java, but it turns out the latest release doesn’t work out of the box.

Update Oct 2015

El Capitan has been released, and some things have changed. I’ve created a new post with instructions for installing just the JRE, which should be fine for most users. I also created a new post with instructions for installing the JDK which is slightly simpler, but contains unnecessary files for users not doing Java software development.


I went to the Oracle Java downloads page and downloaded JDK 8 (it is possible to install the JRE, but not with the installer provided by Oracle). The installation process is straight forward, and I confirmed Java SE 8 was installed correctly, but I still received the alert. Note that the version referenced throughout this post (1.8.0_45) may not be current as you are reading this. You may need to update the version numbers to match the latest Java release.

$ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

I found the answer on StackOverflow, apparently Java isn’t letting OS X know that it can open bundled apps. The solution is to edit /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Info.plist and change:

<key>JVMCapabilities</key>
<array>
    <string>CommandLine</string>
</array>

To:

<key>JVMCapabilities</key>
<array>
    <string>CommandLine</string>
    <string>JNI</string>
    <string>BundledApp</string>
</array>

This got rid of the alert, but despite being able to successfully run my jar from the command line, my app didn’t start. I then tried opening the app from Terminal by running the Java application loader included in my app:

$ MyApp.app/Contents/MacOS/JavaApplicationStub
JavaVM: Failed to load JVM: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bundle/Libraries/libserver.dylib
JavaVM: Failed to load JVM: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bundle/Libraries/libserver.dylib
JavaVM FATAL: Failed to load the jvm library.
[JavaAppLauncher Error] JNI_CreateJavaVM() failed, error: -1

The file libserver.dylib didn’t exist, so after finding the answer on Google Code (which happened to also address the previous issue), I created the directories and created a link to libjvm.dylib with the following commands. Enter your password if/when prompted.

sudo mkdir -p /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bundle/Libraries
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/jre/lib/server/libjvm.dylib /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bundle/Libraries/libserver.dylib

The app can now be opened just like any other, as expected.

Note that I am using Mac OS X Mavericks 10.9.2 Yosemite 10.10.3 and JDK 8 Update 45, not just the JRE. The process should be the same for the JRE and newer Java versions, with minor changes to the folder names (Update 45 JDK has “_45” in the paths above), but I did not test any other option.


Update Dec 2014:

  • This has continued to work after upgrading to Mac OS X Yosemite 10.10.1.
  • A security vulnerability (POODLE) has been found since the last Java release, so I recommend disabling SSL v3.0. The latest release does this by default.
  • I personally recommend disabling Applets and WebStart (either by removing them from JVMCapabilities in the Info.plist mentioned above, or through the Java Control Panel). I removed this from my post.

Update Jan 2015:

A commenter, eric3k, has told me that creating two empty folders may also fix this issue. If the above does not work, you might want to give that a try. The two folders are:

  • /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
  • /System/Library/Java/Support/Deploy.bundle

You can create these with the following commands:

sudo mkdir -p /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
sudo mkdir -p /System/Library/Java/Support/Deploy.bundle

Update Mar 2015:

Beware! The latest JRE installer from Oracle includes adware. Oracle recently released Java 8 Update 45, and added an Ask.com browser toolbar in the installer. At time of writing, it is Step 5 on the Java.com Mac installation help page. I highly recommend deselecting the option to install this additional piece of software. If you accidentally install it, you should uninstall the extension from any and all browsers. You will also have to change your homepage back away from Ask.com.

The JRE installer from Oracle only actually installs the web plugin. If you actually want just the JRE, you will need to download the .tar.gz version from the downloads page, unzip it, and move the unzipped folder (jre1.8.0_45.jre) into /Library/Java/JavaVirtualMachines/ and follow the above instructions. However, you will have to modify the commands slightly, changing “jdk” to “jre” and removing “jre/” from the ln command.


Update Jun 2015 regarding El Capitan:

  • Mac OS X 10.11 El Capitan is currently a Developer Preview. I would recommend against running this as your main operating system.
  • I’ve read that Java 6 is temporarily unavailable in El Capitan.
  • A new mode called “Rootless” is enabled by default, which will prevent you from modifying System files. You can disable it by opening Terminal, running
    sudo nvram boot-args=”rootless=0″

    and restarting your computer.

  • You can disable Rootless mode later with:
    sudo nvram -d boot-args

Published by

Oliver

I am a web developer, I am a software developer.

130 thoughts on “Java SE 8 on Mac OS X”

  1. In macOS Sierra, rootless mode can only be enabled by booting into recovery mode and typing “csrutil disable” in the terminal. System integrity protection can be re-enabled by typing “csrutil enable” in the recovery terminal.

  2. I’ve installed Java 8 and then tried uninstalling and replacing with Java 6… guessing I did that incorrectly though since I still can’t open illustrator.. should I be reinstalling Java 8 again and trying your steps, or do I trying the Java 6 again?

      1. Nope. i got the popup saying I needed Java, which I thought I had… but I figured I was wrong, so I went to the site to download and the only option is Java 8, so I did that, and then once downloading that and still got the popup, I started searching google and came across all this info saying it doesn’t work and I need to do all the terminal things… of which I tried but I don’t exactly have any idea what I’m doing…all I know is that illustrator still isn’t working…

      2. and I’m also not entirely sure what even to do based on the post here…since theres a ton of lines of text to copy and paste with different months… do I do all of them, or just the 2017 one….sorry i’m not familiar with code at all….

  3. Gotta say i’m in the same boat as nechama. Just transferred my Illustrator CS6 to my new MacBook Pro 10.11.6 and it won’t open, same pop up “need Java SE 6 runtime”. Is there any simple answer or is it just time to get into Adobe CC? Thanks. (Also not a programmer and dont want to get into all the code copy/paste)

  4. How do you get OS X 2015-001 to install in El Capitan. It tells me “it can’t” since there is a newer version already there? I see in Apple discussions that it is supposed to uninstall the plug-in from all web browsers. As you can see, I am a complete novice.

    1. The whole point of my blog post/s was to avoid installing the Java version supplied by Apple, because it is very old and unsupported. That being said, “[Java for] OS X 2015-001” is not even available anymore. “Java for OS X 2017-001” from Apple is, however. Perhaps you could try that if you just want the Apple provided version of Java.

    1. I have not tested with macOS High Sierra, but I am not aware of anything that should have changed the process for installing Java 8 on High Sierra.

      1. I just verified that symlink creation does work with High Sierra as well (10.13.6). It runs fine, when running /Applications/ArgoUML.app/Contents/MacOS/JavaApplicationStub from the terminal.

        Only issue is that it won’t if I double-click on the app-link. It shows up a dialog error then saying ““ArgoUML” is damaged and can’t be opened. You should move it to the Trash.”

        Anyway, not a show-stopper since the link to terminal mode execution would show up as the top hit in Spotlight( cmd + space) after couple of executions. So not even by chance, we will have to go for app-link click.

  5. There is an easy trick to execute on OSX Sierra

    sudo mkdir -p /System/Library/Java/JavaVirtualMachines/1.6.0.jdk
    sudo mkdir -p /System/Library/Java/Support/Deploy.bundle

    Boot into Recovery Mode CMD-R, if you encrypted your Harddisk open Drivetool und activate drive. Then start Terminal and do

    sudo mkdir -p /Volumes/Macintosh\ HD/System/Library/Java/JavaVirtualMachines/1.6.0.jdk
    sudo mkdir -p /Volumes/Macintosh\ HD/System/Library/Java/Support/Deploy.bundle

    reboot

    The security features of OSX are not activated in recovery mode.

  6. Thank you Oliver I’m using macOS Mojave and your solution work for me, I did not need to create symlink for libserver.dylib. it was enough for me to modify the info.plist.

Leave a Reply to nechama Cancel reply