I've downloaded and installed Java JDK 8u45 for OS X 10.10.1 and after the installation has completed (successfully), java -version
produces the following:
Unable to locate a Java Runtime to invoke.
Is this an installation bug with this particular version, or have I forgotten to do something?
me@my-laptop$ /usr/libexec/java_home -V
Matching Java Virtual Machines (0):
Default Java Virtual Machines (1):
1.8.0_45, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
Best Answer
That error means Java can't work out which runtime to use. There can be a few reasons for this.
I've had this error in the past because I had more than one copy of Java installed, and none were selected for use in Java Control Panel.
This is from a much older version with a different layout but it should look something like this. Multiple copies listed with tick boxes to tell the system which you want to use.
Another way to check which runtimes you have installed is with the
/usr/libexec/java_home -V
command. Ideally it should return something like the following.Failing that you can check whether you have a $JAVA_HOME environment variable set with
echo $JAVA_HOME
. There is a lot of advice online saying you should set this variable but if you do that then I believe it ignores the settings in Java Control Panel.