0

I'm following along with the Udacity lesson on creating our first jar file. It says to apply the plugin and simply run 'gradle jar'.

    /*

Solution:

*/

apply plugin: 'java' // 1. Apply the Java plugin to the project

//2. Simply run `gradle jar`

however I'm getting an error:

$ gradle jar
> Task :compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Could not find tools.jar. Please check that C:\Program Files (x86)\Java\jre1.8.0_161 contains a valid JDK installation.

I have created an environmental variable JAVA_HOME and added the value C:\Program Files\Java\jdk-12.0.1 suggested here.

I've also gone into the project structure, JDK location, and changed that to C:\Program Files\Java\jdk-12.0.1.

Neither has worked... how do I proceed with this lesson and creating a jar file?

  • Think there is an issue of mismatch as Gradle error message says-Java\jre1.8.0_161 contains a valid JDK installation and you are adding jdk-12.0.1 in Java_Home. Strongly recommend to visit these SO Questions: https://stackoverflow.com/questions/32988601/do-i-need-both-jdk-and-jre https://stackoverflow.com/questions/17601827/should-java-home-point-to-jdk-or-jre – Atul KS Feb 17 '21 at 20:16
  • Yeah I think somehow android studio is reading from the x86 program file and not the regular program files, but I don't know how to change this. – aj mitchell Feb 17 '21 at 23:38
  • These links can help you in this. https://stackoverflow.com/questions/18487406/how-do-i-tell-gradle-to-use-specific-jdk-version https://developer.android.com/studio/intro/studio-config https://stackoverflow.com/questions/57896683/how-to-get-the-jdk-path-in-gradle-within-android-studio – Atul KS Feb 18 '21 at 02:10

0 Answers0