更新
我尝试删除java openjdk的每一个痕迹,安装Oracle Java 8,再次设置我的环境变量,但仍然没有bueno。所以在我做完source ~/.bashrc
之后,我关闭了所有终端,退出了,并且中提琴都被修复了。不过有点麻烦。
OP:
我遇到了SO question,这似乎与我遇到的问题有关。不幸的是,我的export JAVA_HOME=/usr/lib/jvm/default-java
文件中没有usr/bin/gradle
行。
我的错误是JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
但echo $JAVA_HOME
会返回/usr/lib/jvm/java-8-openjdk-amd64/jre
我尝试在真正的JAVA_HOME之间创建一个符号链接,并且一个gradle继续尝试使用但是一个gradle试图使用的不是真的所以我得到了错误ln: failed to create symbolic link '/usr/lib/jvm/java-7-openjdk-amd64/jre': No such file or directory
我尝试挖掘gradlew文件并找到我认为可能违规的代码,但我不能100%确定它是如何工作的,任何时候我编辑文件然后执行cordova run android
所有我的更改都是擦去。
这是我在gradlew中找到的一些代码:
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
我的完整错误报告:
Running command: /home/grant/Development/Projects/ACA/hooks/after_prepare/icons_and_splashscreens.js /home/grant/Development/Projects/ACA
Running command: /home/grant/Development/Projects/ACA/hooks/after_prepare/update_platform_config.js /home/grant/Development/Projects/ACA
ANDROID_HOME=/home/grant/Development/Android
JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/jre
No target specified, deploying to device '05157df5a3d39408'.
ERROR: JAVA_HOME is set to an invalid directory: /usr/lib/jvm/java-7-openjdk-amd64/jre
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation.
ERROR running one or more of the platforms: Error code 1 for command: /home/grant/Development/Projects/ACA/platforms/android/gradlew with args: cdvBuildDebug,-b,/home/grant/Development/Projects/ACA/platforms/android/build.gradle,-PcdvBuildArch=arm,-Dorg.gradle.daemon=true,-Pandroid.useDeprecatedNdk=true
You may not have the required environment or OS to run this project
答案 0 :(得分:1)
首先,Java home应该看起来像/usr/lib/jvm/java-8-oracle
,没有' jre'部分。
其次,它应该放在/ etc / profile文件中:
export JAVA_HOME="/usr/lib/jvm/java-8-oracle"
export PATH=$JAVA_HOME/bin:$PATH