Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio , on windows : JAVA_HOME is not set and no 'java' command could be found in your PATH

I am trying to build my Android app on the command line using Gradle commands. On executing the .gradlew build I am getting the error below:

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.

but I think I have already set the JAVA_HOME Path. If I echo %JAVA_HOME% in a separate cmd.exe window I get:

C:\Program Files\Android\Android Studio\jre

The location above is set as the JDK location

I have to point the JAVA_HOME to the JRE provided by Android and not the system Java, right?

Also, when I run the java command, it shows

'java' is not recognized as an internal or external command, operable program or a batch file

java  -version
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) Client VM (build 25.271-b09, mixed mode, sharing)

Please clarify?

like image 252
Raulp Avatar asked Mar 22 '26 08:03

Raulp


1 Answers

Quick answer:: change JAVA_HOME variable to \jbr enter image description here

  • More details:

Seems like it has to do with Android studio installer. if you will look closely into your "C:\Program Files\Android\Android Studio\jre\bin" folder it will probably be empty!

now check "C:\Program Files\Android\Android Studio\jbr\bin" you will see many java related ".exe" files and other files. change JAVA_HOME variable to point to the jbr.

make sure your "Path" variable also contain a %JAVA_HOME%\bin variable: enter image description here

like image 50
OriO Avatar answered Mar 25 '26 01:03

OriO



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!