【发布时间】:2020-12-11 15:48:00
【问题描述】:
所以,我遇到了这个问题,而且每次我尝试从 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 是一个文件夹,那是怎么回事呢?
【问题讨论】:
-
尝试
.\gradlew(反斜杠而不是斜杠),因为您使用的是 Windows。 -
好的,我找到了一个非常简单的问题答案。只需将 tools.jar 从 jdk 复制到 gradle 尝试使用的 jre 即可。
标签: java gradle command-prompt