SOLUTION: No Java runtime present, requesting install – Mac OS X Yosemite

I was working on a simple java based desktop application today. It was packaged in an executable jar. One of its required features was to launch another executable jar in a separate instance of JVM. Here is my code dealing with this requirement:

This is equivalent of running following command on terminal.

This code was working fine on Windows and Ubuntu. But on Mac, it resulted in a dialogue like this:

To use the "java" command line tool you need to install a JDK.
This error dialogue comes up if you try to use the java command in the terminal after installing Oracle JRE 1.8 on MacOS X Yosemite.

It was a surprise for me as the first app was running fine on the same machine under same configuration. I knew for sure that I have installed Oracle JRE 1.8u60 on this system so java executable should be available on the command line. To investigate further, I launched the Terminal and run  which java. It returned  /usr/bin/java. Then I run  java -version which returned:

and the same dialogue appeared again.

I had no idea how to proceed further. So I started searching on Google. It turned out that, by default,  /usr/bin/java is a symlink to  /System/Library/Frameworks/JavaVM.framework/Versions/A/Commands/java . To make it work on command line, we have to delete it and then recreate it pointing it to the java command in newly installed Oracle JRE which resides at  /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin.

Thus, the two commands that we need to run to fix this issue are given below:

An alternative solution suggested by some other people is to install the full JDK instead of just the JRE. But I have not tested this option because I don’t think it would be appropriate for me to ask a user to install full JDK just to run my app. JRE should be enough for this purpose.




3 thoughts on “SOLUTION: No Java runtime present, requesting install – Mac OS X Yosemite”

  1. *******-iMac:Downloads ********$ sudo rm /usr/bin/java
    rm: /usr/bin/java: Operation not permitted
    *******-iMac:Downloads ********$ sudo ln -s /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java /usr/bin
    ln: /usr/bin/java: Operation not permitted

    – I keep getting this, it wont even let me put in my password, can you help me please?

Leave a Reply