# Eclipse & ANT Classpath

I'm trying to use ANT to build my eclipse project and having problems which look like they're classpath related. I've set the classpath for the project and it appears to be fine when I'm editing it ( none of the import statements are errored and all the classes which are in the external jar files appear to be found. )

When I try to build it using ANT, I get a huge amount of errors which all indcate that it can't find the contents of the external jar files. I've added them in to the classpath for ANT ( Run / External Tools / External Tools ... ) in the Additional Classpath Entries bit and it hasn't made any difference.

Any clues?

Dave
LVL 1
Asked:
###### Who is Participating?

Commented:
Some how the classpath references are missing.  It is highly based on the eclipse workspace (how you have configured).

In reality, in the Ant classpath, only ant.jar and optional.jar is enough.
I sorry as it is environment specific, I wouldn't be able to give you a proper difference.

Regards,
Muruga
0

Commented:
In the Java Build Path of the project you have "Order and Export" Tab.

Check all those jars are checked.  That means they are available for runtime.  Otherwise, they will be used only for compile time.
0

Author Commented:
They were all checked .......
0

Commented:
You are running the project by Run Ant Project button right?

What is the error?  Can you list out a few
0

Author Commented:
I'm right clicking on my build.xml file and then doing "Run Ant ...."

These are the errors I'm getting:

Buildfile: C:\Program Files\eclipse\workspace\CVS_SPAR\SPAR\SPAR_build.xml

compile:
[javac] Compiling 391 source files to H:\OOH\WEB-INF\classes
[javac] C:\Program Files\eclipse\workspace\CVS_SPAR\SPAR\AccountViewElementBuilder.java:19: package org.jdom does not exist
[javac] import org.jdom.*;
[javac] ^
[javac] C:\Program Files\eclipse\workspace\CVS_SPAR\SPAR\AccountViewElementBuilder.java:23: package org.apache.log4j does not exist
[javac] import org.apache.log4j.Logger;
[javac]                         ^
[javac] C:\Program Files\eclipse\workspace\CVS_SPAR\SPAR\AccountViewElementBuilder.java:43: cannot resolve symbol
[javac] symbol  : class Logger
[javac] location: class SPAR.AccountViewElementBuilder
[javac]    static Logger logger = Logger.getLogger(OrchidRouter.log4jLogger + ".AccountViewElementBuilder");
[javac]           ^
[javac] C:\Program Files\eclipse\workspace\CVS_SPAR\SPAR\UserIdRetriever.java:10: package org.jdom does not exist
[javac] import org.jdom.*;
[javac] ^
0

Commented:
keep the xerces and log4j jar in the classpath (of ANT while you run)
0

Author Commented:
I've stuck all the jars in to both the Ant classpath and the additional classpath items and it appears to have worked - what's the difference between the two?
0

Commented:
You always need to specify JARs external to your JDK in the classpath provided to the Javac ANT task.

Good luck!
0

Commented:
No objections... please go ahead...
0

Commented:
Sounds good
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

## Already a member? Login.

All Courses

From novice to tech pro — start learning today.