Tools jar does not exist Eclipse JAVA

I found this question trying to build my project using Ant in Eclipse, and I would get the same error message as above. The suggestions in @Parth's and other answers to edit the Installed JREs is the first step. What I also needed to run Ant successfully was

  1. Right click on build.xml, select "Run As", select "Ant Build..." (note the ...)
  2. Click on the JRE tab
  3. Change the Runtime JRE to the same thing that you updated in the first stage, and press Apply. (That is, the runtime JRE as you specified by "Preferences" -> "Java" -> "Installed JREs", as in @Parth's answer.)

Otherwise it seems that Ant will still try to build with the old JRE that doesn't have tools.jar. Hope this helps someone.

I found the solution to resolve this.

Go to Run Configurations > classpath and under User Enteries you will have tools.jar and its path would be pointing to the old folder. Remove that and click on "Add External Jars" to add the tools.jar from the new path. And that is it.

Right click on your eclipse project, In Preferences go to Java > Installed JREs, select your JDK and click on Edit. In the new Dialog you can add external jars like tools.jar to your execution environment.