-2

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?

2 Answers2

1

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.

JustAnotherDeveloper
  • 2,061
  • 2
  • 10
  • 24
  • 1
    Please be respectful with people that try to help you and try to understand their answers before you lash out at them. Your build is not failing because gradle is not on your path, it is failing because the location of your Java Home, does not contain a valid JDK installation. So you have to set your $JAVA_HOME environment variable to point to a valid JDK installation. As for how to add gradle to your path, [this tutorial on how to install Gradle](https://www.javacodegeeks.com/2013/04/how-to-install-gradle-2.html) might help you. – JustAnotherDeveloper Aug 22 '20 at 14:02
1

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.

Deadbeef
  • 1,499
  • 8
  • 20