Configure Eclipse To Use A Newer Version Of ANT

Author: Steven Neiland

Warning: This blog entry was written two or more years ago. Therefore, it may contain broken links, out-dated or misleading content, or information that is just plain wrong. Please read on with caution.

If you use eclipse you are probably already aware that it comes with ANT built in. However it is more than likely not the most recent version. Fortunately you can install a more recent standalone copy of ANT on your computer and configure eclipse to use that version instead. Here's how...

Step 1: Install ANT

Before we can configure eclipse we must first install the newer version on the computer if it is not already present. For more details on this here are instructions for installing ANT on windows.

Step 2: Configure Eclipse

With ANT installed all you need to do to get eclipse to use it is to open eclipse. Go to the menu bar and open. "windows > preferences > ant > runtime".

Click on the ANT Home button and in the windows that open select the directory you installed ant to. For example "c:\ant"

Step 3: Restart And Test

Now restart eclipse and try run a project build file.

Step 4: Set tools.jar

In some cases you might encounter problems with ANT not being able to find the javac compiler. You may get a message something like this.

[javac] BUILD FAILED: [build file location here]
Unable to find a javac compiler; is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK

Assuming that you have already correctly set the correct JAVA_HOME value then one solution I have found to work for me is to add the tools.jar file to the "Global Entries" list.

To do this reopen "windows > preferences > ant > runtime". Expand the "Global Entries" item in the Classpath tab and click "Add External Jars". Navigate to where your JDK is installed and select the tools.jar file from the lib directory. For me this file was located at "C:\Program Files\Java\jdk\lib\tools.jar"

And that's it. That was'nt too bad was it :-)

Related Blog Postings

Reader Comments

  • Please keep comments on-topic.
  • Please do not post unrelated questions or large chunks of code.
  • Please do not engage in flaming/abusive behaviour.
  • Comments that contain advertisments or appear to be created for the purpose of link building, will not be published.

Archives Blog Listing