jconlin
jconlin

Reputation: 3866

Ant classpath Order

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.

Upvotes: 7

Views: 7000

Answers (3)

Tony BenBrahim
Tony BenBrahim

Reputation: 7290

I had the same problem with Google web toolkit and a servlet 3.0 API file. I needed to make sure my servlet API jar was before the GWT library jars. Here is something that worked:

<path id="classpath">
        <filelist>
            <file name="${build.input}/__lib__/servlet-api.jar"/>
        </filelist>
        <fileset dir="${build.input}/__lib__">
            <include name="*.jar" />
        </fileset>
        <fileset dir="${build.input}/WEB-INF/lib">
            <include name="*.jar" />
        </fileset>
    </path>

Note the jar that needs to be first is listed first in a filelist, then I can add jars from other directories. I tried the bootclasspath in the accepted answer and it did not work.

Upvotes: 3

mtpettyp
mtpettyp

Reputation: 5569

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.

Upvotes: 8

Robert Munteanu
Robert Munteanu

Reputation: 68268

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

Upvotes: 3

Related Questions