[Solved] ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your flutter PATH. in flutter

I installed Android Studio 4.1 and trying to run existing project. But it gives error like this:

ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

Solution #1:

On Ubuntu 20.04 with Android 4.1, this error can be solved using the Snap version with:

flutter config --android-studio-dir=/snap/android-studio/current/android-studio
Respondent: Rony Mesquita

Solution #2:

UPDATE: run flutter upgrade to upgrade to Flutter 1.22.2, which fixes compatibility issues with Android Studio 4.1. See related Flutter release.

This issue has been resolved v

See this issue regarding Android Studio 4.1 and Flutter

You can either downgrade back to Android Studio 4.0.2 or you can
install the latest JDK and update your JAVA_HOME variable and
PATH (OS dependent).

Note that if you choose to continue using 4.1 instead of downgrading,
flutter doctor will tell you Android Studio is not installed.

You need to run flutter config --android-studio-dir="<path to android studio>" in order to fix this issue. flutter doctor will now also
incorrectly report that the Flutter and Dart plugins are not
installed even if they are – you can ignore this.

Respondent: Joseph P

Solution #3:

You need to install Java JDK software which is required for the android studio.

sudo apt install openjdk-11-jdk
Respondent: Matthias

Solution #4:

On Windows, I solved the issue as follows:

  1. Download Java jdk from here and install it.

  2. Set “JAVA_HOME” Environment variable:

    • Open Search, type in “env”, and choose “Edit the system environment variables”.

      enter image description here

    • Click on “Environment Variables…”.

    • Click on “New”.

    • Fill in the “variable name” field with “JAVA_HOME”.

    • Fill in the “variable value” with the path to where Java is installed on your computer. (for me it was under “C:Program FilesJava<jdkversion>”)


    • Click “OK” and close all dialogs.

  3. Restart your IDE / Terminal. (do not skip this step)

Respondent: MendelG

Solution #5:

I set my JAVA HOME to the path,


Then I set my android studio config in flutter by using this command:

flutter config –android-studio-dir=/snap/android-studio/current/android-studio

My system is :
Ubuntu 20.04 with Flutter plugin version as 4.1,

Solution #6:

For ubuntu 20.04 this solution will be appropriate: –

This link solved my problem. In short I would recommend to follow the simple steps, i.e.

  • Upgrade the flutter using flutter upgrade
  • Set the path of the flutter flutter config --android-studio-dir="/path/to/android/studio/"
  • Set the path in bashrc file by opening bashrc file(it is a hidden file)
    export JAVA_HOME="/path/to/android/studio/jre/"
Respondent: Maheep

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .

Most Popular

To Top
India and Pakistan’s steroid-soaked rhetoric over Kashmir will come back to haunt them both clenbuterol australia bossier man pleads guilty for leadership role in anabolic steriod distribution conspiracy