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

/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home

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

What am I missing;

temp.png

Thanks

3 comments
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 https://stackoverflow.com/questions/135688/setting-environment-variables-in-os-x .

1
Comment actions Permalink

Solution provided at stackoverflow worked

http://stackoverflow.com/questions/31215452

0
Comment actions Permalink

The correct answer (if you want $JAVA_HOME and not just any JDK) is http://stackoverflow.com/a/33559474/27358: 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)

(see http://stackoverflow.com/a/6588410/27358)

0

Please sign in to leave a comment.