Search code examples
javaintellij-idea

Intellij JAVA_HOME variable


I started using Gradle and Intellij but I am having problems to configure Gradle's JVM. When I start a new Gradle project I am not allowed to define JVM as my JAVA_HOME variable. The following screenshots show what is happening:

new gradle project

As you can see Intellij says that my JAVA_HOME variable is not defined, however if I type echo $JAVA_HOME I can get my Java directory, in my case: /Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

My ./~bash_profile is configured as follow: export JAVA_HOME=$(/usr/libexec/java_home)

Someone can figure what is happening ? Thank you!


Solution

  • The problem is your "Project SDK" is none! Add a "Project SDK" by clicking "New ..." and choose the path of JDK. And then it should be OK.