Importing Gradle project - getting JAVA_HOME not defined yet

Intellij Idea 14.1.4
Mac OS X Yosemite 10.10.3

From the IDE:
Import Project ->
(Chosen directory to import) ->
Import project from external model, Gradle ->
Gradle Home: /usr/local/Cellar/gradle/2.4/libexec
Gradle JVM: Use JAVA_HOME (not defined yet)

From shell:
> echo $JAVA_HOME


(defined in .profile: export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"

What am I missing;



Comment actions Permalink

On OSX environment variables for Terminal and for GUI apps are different.

IDEA tries to workaround it by evaluating terminal environment, but it may not work in all cases (depends on how you define environment variables for Terminal). For some reason it doesn't work for your specific case.

See also .

Comment actions Permalink

Solution provided at stackoverflow worked

Comment actions Permalink

The correct answer (if you want $JAVA_HOME and not just any JDK) is assuming you have $JAVA_HOME set in your .bash_profile, you can add the following line:

  • launchctl setenv JAVA_HOME "$JAVA_HOME"

Note that if you want to set $JAVA_HOME to the latest Java 8, you need

  • export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)



Please sign in to leave a comment.