Error: Could not create the Java Virtual Machine Mac OSX Mavericks

I just installed the latest Java SDK 7-67 from Oracle on the Mac 10.9.4. I then ran the command java -v in Terminal and I get this message:

Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.


Solution 1:

Normally this error occurs when you invoke java by supplying the wrong arguments/options. In this case it should be the version option.

java -version

So to double check you can always do java -help, and see if the option exists. In this case, there is no option such as v.

Solution 2:

So try uninstalling all other versions other than the one you need, then set the JAVA_HOMEpath variable for that JDK remaining, and you're done.

That's worked for me, I have two JDK (version 8 & 11) installed on my local mac, that causes the issue, for uninstalling, I followed these two steps:

  • cd /Library/Java/JavaVirtualMachines
  • rm -rf openjdk-11.0.1.jdk