user1574598
user1574598

Reputation: 3881

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.

Upvotes: 165

Views: 200803

Answers (7)

abaranji
abaranji

Reputation: 11

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 .

Upvotes: 1

Tal Hakmon
Tal Hakmon

Reputation: 513

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"

Upvotes: 0

Jiangtao Liu
Jiangtao Liu

Reputation: 41

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

Upvotes: 4

Rahul
Rahul

Reputation: 11

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.

Upvotes: 1

Amaresh HD
Amaresh HD

Reputation: 51

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.

Upvotes: 3

Alex Povar
Alex Povar

Reputation: 4960

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.

Upvotes: 0

BatScream
BatScream

Reputation: 19700

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.

Upvotes: 390

Related Questions