Reputation: 3881
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
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
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
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:
Upvotes: 4
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
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_HOME
path variable for that JDK remaining, and you're done.
Upvotes: 3
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
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