I had the same error when I bought a new mac and had to set everything up from scratch.

Basically I had installed only the JRE and not the JDK and I didn't realise it at the time. Check if installing the JDK helps ?