运行gradle -v返回" JAVA_HOME设置为无效目录"即使我有一个有效的JAVA_HOME

时间:2015-09-30 06:32:55

标签: java android gradle

我试图安装并使用gradle 2.7

我正确安装了java:

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)

我正确设置了JAVA_HOME:

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

当我运行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.

我尝试使用此处提供的解决方案Gradle does not recognize the JAVA_HOME I have set和此处Gradle finds wrong JAVA_HOME even though it's correctly set

但位于/usr/local/gradle/gradle-2.7/bin

的gradle文件中不存在该行

有没有人有任何其他建议?

编辑: 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"

0 个答案:

没有答案