I am building a project in Java.
I have this error:
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre6\lib\tools.jar
I have installed a JDK and the folder: C:\Program Files\Java\jre6\lib
is in my system but the file tools.jar
is not there.
Install the Java SDK.
Add a System Environment Variable called JAVA_HOME with the value of JDK location.
Go to Control Panel\System and Security\System. Advanced System Settings, Environment Variables, System Variables, New... Example:
Variable Name:JAVA_HOME
Variable Value: C:\Program Files\Java\jdk1.7.0_21
Close/reopen your CMD window so that the new variable takes effect before attempting to re-run the ant command.
Don't spend too much time looking for
tools.jar
. If you get an error like that, don't be upset.If you already have java JDK 1.5, go to your
lib
folder, and thetools.jar
should be available there. Copy and paste it in your antbin
folder, then try to use the commandant -version
.You should see the expected result.
I have downloaded tools.jar and after that I copied it into path in error message.
C:\Program Files\Java\jdk-11.0.1\bin > paste here tools.jar
After that I have restarted Spring Tool Suit 4 and everything was working. When I was trying to fix that problem I have made new environmental variable: Control Panel / System / Advenced / Environmental variables / new Name : JAVA_HOME Value: C:\Program Files\Java\jdk-11.0.1 But I do not know is it necessary.
You may face similar problem on Ubuntu:
The problem is with JAVA_HOME that is not set properly.
So, on Ubuntu 14.04 x64 using Java8:
If you are in Linux you can solve this by installing java on the system:
I had the same problem even after installing Java JDK and set
JAVA_HOME
to..\jdk1.6.0_45\bin
folder.Ant is still trying to find
tools.jar
inC:\Program Files\Java\jre6\lib
folder.I've fixed it by adding
JAVACMD
environment variable and set path for it tojava.exe
in thejdk
folder.In my case it was
C:\Program Files\Java\jdk1.6.0_45\bin\java.exe