Search code examples
androidfluttermacos

Cannot execute /usr/lib/jvm/java-17-openjdk-amd64/bin/java to determine the version


The version of my java is 21.

However the error says it's looking for v17.

I tried to find and fix the problem. But there aren't any solution to this available. I am trying to avoid reinstalling Android Studio.

This is mac m1. Please guide me here.

[Cannot execute /usr/lib/jvm/java-17-openjdk-amd64/bin/java to determine the version1


Solution

  • I was able to resolve this with the help of chatgpt...

    Flutter was pointing to the wrong jdk all this while...

    Run the cmd: flutter config --list

    I got this...

    All Settings:
    enable-web: true
    ...
    ...
    jdk-dir: /usr/lib/jvm/java-17-openjdk-amd64/
    android-studio-dir: /Applications/Android Studio.app

    jdk-dir was set to old version of java...

    I was able to update this with the following cmd

    flutter config --jdk-dir /Library/Java/JavaVirtualMachines/jdk-21.jdk/Contents/Home

    Now when I run flutter doctor, I'm getting this

    flutter doctor