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.
- Open System Preferences and click on the Java icon this should launch the "Java Control Panel".
- Then select the Java tab and click "View...", this should bring up the "Java Runtime Environment Settings" window.
- My guess is that you'll find more than one instance of Java listed here. Tick the box beside the one you want to use and click OK.
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.
Matching 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
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.
echo $JAVA_HOME
return anything?/usr/lib/jvm/java-7-oracle
. I just bought this mac the other day, java is one of the first things I tried to install. When I initially ranjava -version
it told me it needed to be installed.export JAVA_HOME=/usr/lib/jvm/java-7-oracle
in a file something like .profile or .bashrc or something along that line in /Users/YOURUSERNAME.