Gradle Could not find tools.jar
Asked Answered
S

6

29

I am trying to make a game with LibGdx. I love it! It is sooo simple and a lot better than JME3 and LWJGL. But trying to package it I am having an error. Here is an image of the gui for Gradle: http://prntscr.com/845kyx and here is a the full debug error: http://pastebin.com/ugdfySg1 Now I don't know how to debug those errors and what not, so I hope someone can help. I have also tried to re-create the entire project, and make it a eclipse valid project, instead of just Gradle. None of that worked. enter image description here

Spaceport answered 13/8, 2015 at 13:6 Comment(3)
Can you please include the screenshots and error log in your post?Shields
I did they are at the links prntscr.com/845kyx and pastebin.com/ugdfySg1Spaceport
I meant if you could include them directly, not as links. If these services are defunct, your question and the answers become useless for others with the same problem.Shields
F
19

You have to set the system property "java.home" and the environment variable JAVA_HOME to a valid JDK.

To set the environment variable run: export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

Fragrance answered 13/8, 2015 at 13:15 Comment(2)
i think you can elaborate this answer, like how to set system property in linux etcAdmixture
Also add the following command: export PATH="${PATH}:${JAVA_HOME}/bin"Devonna
B
37

I have a file called gradle.properties at the root of my project with the following property:

org.gradle.java.home=C:\\Program Files\\Java\\jdk1.8.0_74

org.gradle.java.home needs to point to a valid JDK location.

Without this file, I get the same error (Could not find tools.jar). With the file present, this is no longer an issue.

Bartonbartosch answered 28/3, 2016 at 19:15 Comment(3)
Not usable across several developers with different configurations!Warenne
@MarkusL your statement is correct. Each developer must create his or her own gradle.properties. The file is not intended for sharing.Bartonbartosch
this worked for me when i set it to this in the gradle.properties org.gradle.java.home=/usr/lib/jvm/default-java/Evelunn
C
28

For me was solution this:

yum install java-1.8.0-openjdk-devel

Or for newer CentOS/Fedora/RHEL versions:

dnf install java-devel
Creese answered 26/1, 2017 at 11:27 Comment(2)
For me that works in Fedora 24+: sudo dnf install java-1.8.0-openjdk-develKendyl
Faced same issue while I was trying to install voldemort kv store on centos 7.2 yum install java-1.8.0-openjdk-devel solved for meLection
F
19

You have to set the system property "java.home" and the environment variable JAVA_HOME to a valid JDK.

To set the environment variable run: export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

Fragrance answered 13/8, 2015 at 13:15 Comment(2)
i think you can elaborate this answer, like how to set system property in linux etcAdmixture
Also add the following command: export PATH="${PATH}:${JAVA_HOME}/bin"Devonna
S
14
sudo apt-get install openjdk-7-jdk

Fixed it for me for a Jenkins job.

Socinian answered 12/1, 2016 at 0:18 Comment(3)
Alternately, sudo apt-get install openjdk-8-jdkNevertheless
At least in Ubuntu Xenial package openjdk-8-jdk-headless provides /usr/lib/jvm/java-8-openjdk-amd64/lib/tools.jarMonti
On my WSL only openjdk-8-jdk has tools.jar ,openjdk-8-jdk-headless doesn't work.Periwig
M
7

If we already have a lot of different distro answers I might as well add the Arch answer:

sudo pacman -S jdk8-openjdk
Mortenson answered 18/2, 2018 at 18:9 Comment(0)
E
1

This works for me as a temporary solution. At the root of my project in "gradle.properties" file I have line:

org.gradle.java.home=/usr/lib/jvm/default-java/
Elizaelizabet answered 5/7, 2021 at 22:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.