views:

372

answers:

2

How do I set the classpath order in ant?

Specifically, When I am trying to run my ant build, I need it to pick up a class in a jar (jaxws-api.jar) instead of the same class which is in the jre. I am currently setting the classpath to explicitly include those jars however it seems to still pick up the jre first. What I am looking for is some type of equivalent to Order/Export in eclipse under the "Build Configuration" menu.

Edit: I'll be more explicit. I have some classes which were generated with CXF 2.1.3. They call javax.xml.ws.Service#getPort(QName, Class, WebServiceFeature...). I am using Java version 1.6.02. This method does not exist in that class in that version. However, it does exist in the jaxws version of the class (and later versions of the JRE class). When I try to do an ant build, the JRE class is always picked up first before the jaxws version. This makes my compilation fail. How can I modify my classpath to put the JRE last?

I can't change the JRE version, so please don't suggest that as a fix unless it is the only possible one.

+1  A: 

Jars in the ant classpath are placed in the order you declare them.

Robert Munteanu
It's worth noting that this is true if you add them directly in a `<pathelement>` in the `<junit>` `<classpath>` element, but referring to a separate `<path>` via `refid` apparently does not honor the order you declare them in.
Alan Krueger
+3  A: 

Looks like you need to use the bootclasspath setting in the Javac or Java Ant task.

You can always do ant -v to get verbose output of your Ant build.

mtpettyp