这个问题在这里已经有了答案:
Unable to locate tools.jar
(34 个回答)
1年前关闭。
所以,我遇到了这个问题,每次我尝试从 Eclipse 运行 Gradle 时都会出现这个错误:
Working Directory: C:\Users\Owen\eclipse-workspace\SimpleMultiplycationProgram\SimpleMultiplycationProgramApp
Gradle user home: C:\Users\Owen\.gradle
Gradle Distribution: Gradle wrapper from target build
Gradle Version: 4.3.1
Java Home: C:\Program Files\Java\jre1.8.0_251
JVM Arguments: None
Program Arguments: None
Build Scans Enabled: false
Offline Mode Enabled: false
Gradle Tasks: run
:SimpleMultiplycationProgramApp:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':SimpleMultiplycationProgramApp:compileJava'.
> Could not find tools.jar. Please check that C:\Program Files\Java\jre1.8.0_251 contains a valid JDK installation.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 13s
1 actionable task: 1 executed
所以,我开始尝试解决这个问题,但是所有的 stackoverflow 问题和教程都说要执行类似运行 ./gradle biuld
的操作。它给了我这个错误(来自cmd):'.' is not recognized as an internal or external command,
operable program or batch file.
`/gradle biuld' 给了我:'/gradle' is not recognized as an internal or external command,
operable program or batch file.
和 gradle biuld
给我:'gradle' is not recognized as an internal or external command,
operable program or batch file.
而 C:\Users\Owen.gradle 是一个文件夹,那么这是怎么回事呢?
最佳答案
这似乎是关于两个不相关的问题。一方面,您的 PATH 上似乎没有 gradle,因此无法识别该命令。然后您还缺少 rt.tools。看看有没有this other question帮你解决。您似乎只下载了 JRE 而没有下载 JDK。
关于java - 我不能用 gradle 运行任何东西,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63536720/