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

JavaTerminal

Java Problem Overview


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.

Java Solutions


Solution 1 - Java

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 - Java

> 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

Solution 3 - Java

if you tried running java with -version argument, and even though the problem could not be solved by any means, then you might have installed many java versions, like JDK 1.8 and JDK 1.7 at the same time.

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.

Solution 4 - Java

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

I was getting this Error due to incorrect syntax using in the terminal. I was using java - version. But its actually is java -version. there is no space between - and version. you can also cross check by using java -help.

i hope this will help.

Solution 5 - Java

I faced this issue ,when i tried to launch uiautomatorviewer.I had java 13 version . Later i downloaded the java 8 version . Go to terminal and open .bash_profile. Enter export JAVA_HOME=$(/usr/libexec/java_home -v 1.8). Save and Exit .

Solution 6 - Java

There can be one more reason for such behavior - you delete current working directory.

For example:

# in terminal #1
cd /home/user/myJavaApp

# in terminal #2
rm -rf /home/user/myJavaApp

# in terminal #1
java -jar myJar.jar

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

Solution 7 - Java

Try : java -version , then if you see java 11

try to delete with terminal : cd /Library/Java/JavaVirtualMachines rm -rf openjdk-11.0.1.jdk

if it doesn't try delete manually:

  1. click on finder
  2. go to folder
  3. post /Library/Java/JavaVirtualMachines
  4. delete java 11 .

then try java version and you will see : java version "1.8.0_191"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser1574598View Question on Stackoverflow
Solution 1 - JavaBatScreamView Answer on Stackoverflow
Solution 2 - JavaJiangtao LiuView Answer on Stackoverflow
Solution 3 - JavaAmaresh HDView Answer on Stackoverflow
Solution 4 - JavaRahulView Answer on Stackoverflow
Solution 5 - JavaabaranjiView Answer on Stackoverflow
Solution 6 - JavaAlex PovarView Answer on Stackoverflow
Solution 7 - JavaTal HakmonView Answer on Stackoverflow