5

I'm trying to install and use gradle 2.7

I have java installed properly:

java -version
java version "1.8.0_11"
Java(TM) SE Runtime Environment (build 1.8.0_11-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.11-b03, mixed mode)

I have my JAVA_HOME set correctly:

echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home

When I run gradle -v:

ERROR: JAVA_HOME is set to an invalid directory: /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.

I tried to use the solution given here Gradle does not recognize the JAVA_HOME I have set and here Gradle finds wrong JAVA_HOME even though it's correctly set

but that line does not exist in my gradle file located at /usr/local/gradle/gradle-2.7/bin

Does anyone have any other suggestions?

Edit: cat ~/.bash_profile

export JAVA_HOME=$(/usr/libexec/java_home)
export JDK_HOME=$(/usr/libexec/java_home)
export PATH=/Users/eghdk/Dev/Android/SDK/platform-tools:/Users/eghdk/Dev/Android/SDK/tools:$PATH
export ANDROID_HOME=/Users/eghdk/Dev/Android/SDK
# Adding Gradle to system path
export GRADLE_HOME=/usr/local/gradle/gradle-2.7
PATH=$GRADLE_HOME/bin:$PATH
export PATH
# Turning on the Gradle daemon by default
export GRADLE_OPTS="-Dorg.gradle.daemon=true"
Community
  • 1
  • 1
EGHDK
  • 17,818
  • 45
  • 129
  • 204
  • could you try to run this command `export | grep JAVA` in terminal? – kucing_terbang Sep 30 '15 at 06:44
  • does the directory /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home have a `bin` subdirectory with `java` in it? – Henry Sep 30 '15 at 09:36
  • @kucing_terbang output: `declare -x JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents"Home` – EGHDK Oct 01 '15 at 06:08
  • @Henry yes, `/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/bin` has java and other java* files in it. – EGHDK Oct 01 '15 at 06:10
  • @EGHDK Ok, then, is the command (`declare -x`) is put into something like `.profile` or `.bash_profile` file? – kucing_terbang Oct 01 '15 at 13:18
  • I ran `cat ~/.bash_profile` and put the output into an edit of the question @kucing_terbang – EGHDK Oct 01 '15 at 14:14
  • Is your previous output a typo, e.g., that quote between `Contents` and `Home`? What version of OS X? I'm running Java build 1.8.0_45-b14 and Gradle 2.7 and I can't reproduce this, but I also installed Gradle in my user directory because when it comes to Java libraries I never do any automatic installation (e.g., no homebrew of Java artifacts). – Dave Newton Oct 01 '15 at 14:26
  • @DaveNewton not a typo. That's the exact copy and paste of the output. I'm guessing the `"` shouldn't be there? – EGHDK Oct 01 '15 at 15:04
  • Not unless you have a particularly funky Java install ;) It's disturbing that the echo and gradle have the correct `/`, though. – Dave Newton Oct 01 '15 at 15:16
  • @DaveNewton do you have any idea of what to do to fix that? – EGHDK Oct 01 '15 at 15:50

0 Answers0