Unable to locate tools.jar

2019-01-01 15:22发布

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.

27条回答
柔情千种
2楼-- · 2019-01-01 15:48
  1. Install the Java SDK.

  2. 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

  3. Close/reopen your CMD window so that the new variable takes effect before attempting to re-run the ant command.

查看更多
刘海飞了
3楼-- · 2019-01-01 15:49

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 the tools.jar should be available there. Copy and paste it in your ant bin folder, then try to use the command ant -version.

You should see the expected result.

查看更多
临风纵饮
4楼-- · 2019-01-01 15:50

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.

查看更多
不流泪的眼
5楼-- · 2019-01-01 15:51

You may face similar problem on Ubuntu:

Embedded error: tools.jar not found: /usr/lib/jvm/java-7-openjdk-amd64/jre/../lib/tools.jar

The problem is with JAVA_HOME that is not set properly.

So, on Ubuntu 14.04 x64 using Java8:

sudo apt-get install openjdk-8-jdk openjdk-8-jre
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
查看更多
梦寄多情
6楼-- · 2019-01-01 15:52

If you are in Linux you can solve this by installing java on the system:

sudo apt-get install openjdk-7-jdk openjdk-7-jre
查看更多
何处买醉
7楼-- · 2019-01-01 15:54

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 in C:\Program Files\Java\jre6\lib folder.
I've fixed it by adding JAVACMD environment variable and set path for it to java.exe in the jdk folder.
In my case it was C:\Program Files\Java\jdk1.6.0_45\bin\java.exe

查看更多
登录 后发表回答