简体   繁体   中英

Error:“ Unable to find any JVMs matching version ”1.8“.”

When I run flutter create x or flutter doctor I get the following message "Unable to find any JVMs matching version 1.8 .

I also tried following another thread on StackOverFlow for this issue but it did not help because it did not specify what to do if you already have java installed. At the moment when I run java-version I get the following message:

java version 13.0.1 2019-10-15 Java(TM) SE Runtime Environment (build 13.0.1+9) Java HotSpot(TM) 64-Bit Server VM (build 13.0.1+9, mixed mode, sharing)

Thank you in advance for the help!

EDIT: I found a solution!

echo export "JAVA_HOME=\$(/usr/libexec/java_home -v 1.7)" >> ~/.bash_profile

All I did was replace 1.7 with a JDK I already had installed and now it works. The thread can be found below:

How to set JAVA_HOME environment variable on Mac OS X 10.9?

You've installed java 13 while your application is looking for java 8. So install java 8 and set it your default jvm/jre (set your JAVA_HOME).

Hope it helps !

Just a guess, as I do not use Flutter…

Java changed its version numbering scheme

Java changed the way it reports its own version number. In earlier versions, the number was always 1.xy where x is what we colloquially considered to be the version. Eventually Sun/Oracle decided to make that common usage official. So now later versions such as the one you are using dropped the 1. . Rather than 1.13.y Java now identifies itself as 13.y .

Update Flutter

This change in version numbering scheme can confuse old software that expected the version number to always report 1.xy . Such software needs to be updated to understand the new number scheme.

I suggest you update your Flutter library to a more recent updated version, if one exists.

Downgrade Java

Most Java 8 apps should run without a problem on Java 13 if it weren't for this tiny version number interpretation issue. So you should not have to downgrade from Java 13 to Java 8 to run your app. But you might need to downgrade to resolve this issue if Flutter was never updated properly.

If you do need to downgrade, here is a flowchart I made to help locate a vendor of a Java implementation. This chart is aimed at Java 11, but most of these venders provide Java 8 implementations as well.

指导您为 Java 11 实施选择供应商的流程图

选择 Java 供应商的动机

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM