Gradle – Invalid JDK configuration found, while importing a project via Gradle

gradleintellij-idea

I have installed IntelliJ and I need to import a Gradle project.

I have build the gradle project using command prompt with the gradlew build command.

At the IntelliJ welcome page, I have proceeded with proper instructions, and when I choose "Finish". I get the following error:

Invalid Gradle JDK configuration found. Open Gradle Settings JAVA_HOME ennvironment variable not set.

When I click on "Open Gradle Settings" it pop up with error of Not found with a path under IntelliJ directory in Program files and searching in jre/jre/bin/….etc.

Best Answer

Deleting .gradle and .idea will likely solve the problem.

So:

  • Close the project
  • Go to the project dir and delete .gradle and .idea
  • Get back and re-open the project using the IDE

These two must be generated locally on your PC and not pulled from a remote or somewhere else (Also they should be in .gitignore).

In my case the reason was that these two folders were generated on another computer and I had opened a project with these two folders existing before.