Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 10 Gradle: JAVA_HOME is set to an invalid directory

I was trying to run ./gradlew bootRun in both Git Bash and PowerShell, and got this error: ERROR: JAVA_HOME is set to an invalid directory: C:\Program Files\Java\jre1.8.0_121

The gradlew file is inside the project directory that cloned from git. It is a practice project from Spring official guide. There's also a gradle.bat file with these lines:

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%\bin\java.exe 

I also tried to run Eclipse EE, which got no problem. The environment setting should be no problem.

like image 493
hanabi_noir Avatar asked May 20 '17 04:05

hanabi_noir


People also ask

How do you fix please set the JAVA_HOME variable in your environment to match the location of your Java installation?

Right click My Computer and select Properties. On the Advanced tab, select Environment Variables, and then edit JAVA_HOME to point to where the JDK software is located, for example, C:\Program Files\Java\jdk1.

How do you check JAVA_HOME path is set or not?

Verify JAVA_HOMEOpen a Command Prompt window (Win⊞ + R, type cmd, hit Enter). Enter the command echo %JAVA_HOME% . This should output the path to your Java installation folder. If it doesn't, your JAVA_HOME variable was not set correctly.


1 Answers

In addition to Ernest's answer, the JAVA_HOME it wants is the actual directory, not the bin folder like the path wants for javac. Took me a while to work that out

like image 115
Kyrei Avatar answered Nov 03 '22 11:11

Kyrei