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

You have to set the JAVA_HOME Environment Variable.

On Windows, I solved the issue as follows:

  1. Download the Java JDK from here and install it. (This links to version 15, which requires you to create an account in order to download. Version 16 is available to download without creating an account, but it has caused me an error that required me to downgrade.)

  2. Set the “JAVA_HOME” Environment Variable:

    • Open Windows 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 Files\Java\<jdkversion>”.)

      Screenshot

    • Click “OK” and close all dialogs.

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

Leave a Comment