Hello Guys How are you all? Hope You all are fine. I just Installed Latest Android Studio in my windows machine trying to run the existing project. But it gives an error like this: ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your flutter PATH. in flutter. So today Here I come with all possible solutions for this error.
We are providing you all possible solutions to solve this error. let’s start this article without wasting your time.
How JAVA_HOME is not set and no ‘java’ command could be found in your flutter PATH Occurs ?
I just Installed Latest Android Studio in my windows machine trying to run the existing project. But it gives an 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.
How to Solve JAVA_HOME is not set and no ‘java’ command could be found in your flutter PATH Error?
- How to Solve JAVA_HOME is not set and no 'java' command could be found in your flutter PATH Error?
To solve JAVA_HOME is not set and no 'java' command could be found in your flutter PATH If you have installed Android Studio from the website and not using snap, run
flutter config --android-studio-dir=/usr/local/android-studio
. Just open your terminal. Run this command flutter config –android-studio-dir=' flutter doctor That's It. - JAVA_HOME is not set and no 'java' command could be found in your flutter PATH
To solve JAVA_HOME is not set and no 'java' command could be found in your flutter PATH If you have installed Android Studio from the website and not using snap, run
flutter config --android-studio-dir=/usr/local/android-studio
. Just open your terminal. Run this command flutter config –android-studio-dir=' flutter doctor That's It.
Solution 1
If you have installed Android Studio from the website and not using snap, run flutter config --android-studio-dir=/usr/local/android-studio
- Just open your terminal.
- Run this command flutter config –android-studio-dir='<path to android studio>
- flutter doctor
- Thats It.
If Still your problem not resolved then just follow Solution 2 to set your JAVA_HOME path.
Solution 2: How to Set JAVA_HOME Path
How to Set JAVA_HOME Path In Windows.
- Download Java JDK from here and install it.
- Open Search, type in “environment variable”, and choose “Edit the system environment variables”.
- 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>”)
- Click “OK” and close all dialogs.
- Restart your IDE / Terminal. (do not skip this step)
How to Set JAVA_HOME Path In Ubuntu
To Set JAVA_HOME / PATH for a single user, Login to your account and open .bash_profile file
$ vi ~/.bash_profile
Set JAVA_HOME as follows using syntax export JAVA_HOME=<path-to-java>
. If your path is set to /usr/java/jdk1.5.0_07/bin/java, set it as follows:
export JAVA_HOME=/usr/java/jdk1.5.0_07/bin/java
Set PATH as follows:
export PATH=$PATH:/usr/java/jdk1.5.0_07/bin
Feel free to replace /usr/java/jdk1.5.0_07 as per your setup. Save and close the file. Just logout and login back to see new changes. Alternatively, type the following command to activate the new path settings immediately:
$ source ~/.bash_profile
OR
$ . ~/.bash_profile
Verify new settings:
$ echo $JAVA_HOME
$ echo $PATH
Tip: Use the following command to find out exact path to which java executable under UNIX / Linux:
$ which java
Please note that the file ~/.bashrc is similar, with the exception that ~/.bash_profile runs only for Bash login shells and .bashrc runs for every new Bash shell.
How to Set JAVA_HOME Path In macOS
In Mac OSX 10.5 or later, Apple recommends to set the $JAVA_HOME variable to /usr/libexec/java_home
, just export $JAVA_HOME
in file ~/. bash_profile
or ~/.profile
.
Open the terminal and run the below command.
$ vim .bash_profile
export JAVA_HOME=$(/usr/libexec/java_home)
save and exit from vim editor, then run the source command on .bash_profile
$ source .bash_profile
$ echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/1.7.0.jdk/Contents/Home
Summery
So, It’s All About ERROR: JAVA_HOME is not set and no ‘java’ command could be found in your flutter PATH. in flutter Error. I hope this tutorial helps you solve your error. Please Comment Below if You stucks anywhere with my code.
Also Check Out Below Tutorials
- Could not resolve all files for configuration ‘classpath’. Could not find lint-gradle-api.jar
- Flutter plugin not installed; this adds Flutter specific functionality
- TextField inside of Row causes layout exception: Unable to calculate size
- PluginRegistry cannot be converted to FlutterEngine In Flutter
- How To Make Round button with text and icon in flutter?
Leave a Reply