2

I found this post but the answer did not solve my problem. The answers only address windows systems and provide file paths which are not helpful for the OS I am running. I am running openSUSE Leap 15 with Java 1.8, changing the OS or Java version is not an option.

When I try to build with the command ./gradlew clean build i get the following error:

:buildtools:compileJava FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':buildtools:compileJava'.
> Could not find tools.jar. Please check that /usr/lib64/jvm/java-1.8.0-openjdk-1.8.0/jre 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.

BUILD FAILED

Total time: 15.364 secs

I have checked my Java installation like this:

 $> rpm -qa | grep java
javapackages-tools-5.0.0+git20180104.9367c8f6-lp150.1.2.x86_64
timezone-java-2018g-lp150.2.13.1.noarch
java-1_8_0-openjdk-1.8.0.181-lp150.2.6.1.x86_64
libjavascriptcoregtk-4_0-18-2.20.5-lp150.2.6.1.x86_64
java-1_8_0-openjdk-headless-1.8.0.181-lp150.2.6.1.x86_64

I also checked out JAVA_HOME:

$> echo $JAVA_HOME
/usr/lib64/jvm/jre-1.8.0-openjdk
Human
  • 726
  • 8
  • 27
  • What does your gradle file look like, it says you're referencing to the `jre` while you should be referencing to the `jdk` to use `tools.jar`. – Mark Nov 09 '18 at 13:21
  • 3
    Gradle requires a JDK (see https://docs.gradle.org/current/userguide/installation.html#sec:prerequisites ) : your $JAVA_HOME is pointing on a JRE installation, which does not contain the needed `tools.jar`. Can you reconfigure JAVA_HOME to point on your JDK instead of JRE ? – M.Ricciuti Nov 09 '18 at 13:23

1 Answers1

3

The comments inspired me to find a solution. Apparently installing the package java-1_8_0-openjdk will only provide the OpenJDK 8 runtime environment. I wrongly expected it to include the development tools because of the 'jdk' in its name (Java Development Kit).

My problem was solved by simply installing the package java-1_8_0-openjdk-devel which actually includes the development tools, like this: sudo zypper in java-1_8_0-openjdk-devel.

The command zypper se jdk can help you to figure out the status of your jdk installation. After installing the package java-1_8_0-openjdk-devel you should see an i+ next to the package name. You should be able to spot the following two lines:

i+ | java-1_8_0-openjdk        | OpenJDK 8 Runtime Environment      | package
i+ | java-1_8_0-openjdk-devel  | OpenJDK 8 Development Environment  | package
Human
  • 726
  • 8
  • 27