简体   繁体   English

Gradle找不到JDK

[英]Gradle cannot find JDK

I've created a gradle project with the following configuration: 我已经使用以下配置创建了一个gradle项目:

group '...'
version '0.0'

apply plugin: 'java'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

test {
    useTestNG()

    beforeTest { descriptor ->
        logger.lifecycle("Running test: " + descriptor)
    }
}

When I execute "gradle build" I have the following error message: 当我执行“gradle build”时,我有以下错误消息:

Cannot find System Java Compiler. 找不到System Java Compiler。 Ensure that you have installed a JDK (not just a JRE) and configured your JAVA_HOME system variable to point to the according directory. 确保已安装JDK(而不仅仅是JRE)并将JAVA_HOME系统变量配置为指向相应目录。

This is weird since I have $JAVA_HOME set: 这很奇怪,因为我设置了$ JAVA_HOME:

✗ echo $JAVA_HOME
/usr/lib/jvm/java-8-oracle
✗ $JAVA_HOME/bin/javac
Usage: javac <options> <source files>
where possible options include:

I've found a solution. 我找到了解决方案。

To fix this issue I simply executed: 要解决这个问题,我只需执行:

./gradlew build

This did the trick. 这样做了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM