我无法使用Gradle运行任何东西。

huangapple go评论60阅读模式
英文:

I can not run anything with gradle

问题

我有一个问题,就是每次我尝试从Eclipse运行Gradle时都会出现以下错误:

工作目录:C:\Users\Owen\eclipse-workspace\SimpleMultiplycationProgram\SimpleMultiplycationProgramApp
Gradle用户主目录:C:\Users\Owen\.gradle
Gradle分发:来自目标构建的Gradle包装器
Gradle版本:4.3.1
Java主目录:C:\Program Files\Java\jre1.8.0_251
JVM参数:无
程序参数:无
构建扫描已启用:false
离线模式已启用:false
Gradle任务:run

:SimpleMultiplycationProgramApp:compileJava 失败

FAILURE:构建失败,发生异常。

* 出现了什么问题:
任务“:SimpleMultiplycationProgramApp:compileJava”的执行失败。
> 找不到tools.jar。 请检查C:\Program Files\Java\jre1.8.0_251中是否包含有效的JDK安装。

* 尝试:
运行时添加--stacktrace选项以获取堆栈跟踪。 运行时添加--info或--debug选项以获取更多日志输出。

* 在https://help.gradle.org获取更多帮助。

13秒内构建失败,有1个可操作任务:1个已执行

因此,我开始尝试修复这个问题,但所有的stackoverflow问题和教程都说要做类似运行 ./gradle biuld 这样的操作,但在cmd中会出现以下错误:

“.” 不被识别为内部或外部命令、可执行程序或批处理文件。

/gradle biuld 给我:

“/gradle” 不被识别为内部或外部命令、可执行程序或批处理文件。

gradle biuld 给我:

“gradle” 不被识别为内部或外部命令、可执行程序或批处理文件。

而 C:\Users\Owen.gradle 是一个文件夹,发生了什么问题?

英文:

So, I have this problem, and it is that every time I try to run Gradle from Eclipse it gives me this error:

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

So, I started trying to fix this but all the stackoverflow questions and tutorials say to do something like running ./gradle biuld it gives me this error (from cmd):

'.' is not recognized as an internal or external command,
operable program or batch file.

`/gradle biuld' gives me:

'/gradle' is not recognized as an internal or external command,
operable program or batch file.

and gradle biuld gives me:

'gradle' is not recognized as an internal or external command,
operable program or batch file.

and C:\Users\Owen.gradle is a folder, so what is going on?

答案1

得分: 1

这似乎涉及到两个无关的问题。首先,您的路径中似乎没有gradle,因此命令无法被识别。其次,您还缺少了rt.tools。查看一下这个其他问题,看看是否能帮助您解决问题。您似乎只下载了JRE而没有下载JDK。

英文:

This seems to be about two unrelated problems. For one, you don't seem to have gradle on your PATH, hence why the command is not recognized. And then you're also missing rt.tools. See if this other question helps you solve it. You seem to have downloaded only the JRE and not the JDK.

答案2

得分: 1

我看到你正在使用JRE而不是JDK。可能你把$JAVA_HOME环境变量指向了JRE,而实际上应该指向JDK。

要使用gradle,如果在你的项目目录中有一个名为"gradlew"的wrapper,可以这样调用它:./gradlew ...
但如果没有的话,你需要运行"wrapper"任务来生成它们。

你也可以选择安装gradle。但要记住,这不会解决你的问题。你可以查看这篇文章来安装gradle。

英文:

It appears to me that you are using a JRE instead of JDK. Possible that you pointed $JAVA_HOME environment variable to a JRE when it was meant to be JDK.

To use gradle, if you have a wrapper in your project directory named "gradlew", call it like this: ./gradlew ...
But if you don't have it, you should run the "wrapper" task to generate them.

You can also install gradle instead. But keep in mind it doesn't help with your issue. Take a look at this article for installing gradle.

huangapple
  • 本文由 发表于 2020年8月22日 21:29:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/63536720.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定