Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8623837
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:22:44+00:00 2026-06-12T07:22:44+00:00

I am trying to get Ant to compile my project, which has the following

  • 0

I am trying to get Ant to compile my project, which has the following directory structure:

MyProject/
    src/main/java/
        com/
            <The rest of my source>
    gen/
        bin/
            main/
                <Where I want all Java sources compiled to>
    lib/
        main/
            <All of my dependencies>
    build.xml
    build.properties

Here’s my Ant task:

<path id="src.main.java.path">
    <fileset dir="src/main/java">
        <include name="**.*java"/>
    </fileset>
</path>

<path id="lib.main.path">
    <fileset dir="lib/main">
        <include name="**.*jar"/>
    </fileset>
</path>

<target name="compile">
    <javac includeantruntime="true" srcdir="src/main/java" destdir="gen/bin/main">
        <!--
        Define a new classpath composed of all main Java sources and main Java dependencies,
        and use them for this compilation.
        -->
        <classpath>
            <pathelement path="src.main.java.path"/>
            <pathelement path="lib.main.path"/>
        </classpath>
    </javac>
</target>

I should mention that build.xml is located at the project root directory, and that its basedir attribute is set to "." (the project root dir).

When I run the “compile” task I get 100+ compiler errors that it can’t find any of my project dependencies (such as Guice, Joda-Time, XStream, etc.):

compile:
    [javac] Compiling 53 source files to /<path-to-my-project-root>/MyProject/gen/bin/main
    [javac] /<path-to-my-project-root>/MyProject/src/main/java/org/me/Widget.java:37: package com.google.inject does not exist
    [javac] import com.google.inject.AbstractModule;
    [javac]                         ^
    [javac] /<path-to-my-project-root>/MyProject/src/main/java/org/me/MyWidget.java:45: cannot find symbol
    [javac] symbol: class AbstractModule
    [javac] public class AppUziContext extends AbstractModule {
    [javac]            

BUILD FAILED
/<path-to-my-project>/MyProject/build.xml:51: Compile failed; see the compiler error output for details.

… the list is 100+ errors that all look like this, but are different for every dependency that it can’t find.

I believe the problem lies somewhere in the paths I’ve configured and am referencing inside javac/classpath, but after reading the Ant docs I can’t figure out where I’m going awrye. Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T07:22:45+00:00Added an answer on June 12, 2026 at 7:22 am

    Try this in your target:

    <classpath>
        <path refid="src.main.java.path"/>
        <path refid="lib.main.path"/>
    </classpath>
    

    I usually make complete classpaths for targets, then use a one-liner classpath within the target:

    <path id="target.class.path">
        <path refid="src.main.java.path"/>
        <path refid="lib.main.path"/>
    </path>
    

    Then in the target:

    <classpath refid="target.class.path"/>
    

    pathelement isn’t very well documented, this is the best that you’ll get from the ant site. Note that in these examples, <pathelement path= is always used with a property, otherwise it’s <pathelement location taking an actual folder name (which could also be a property).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to build my project with ANT in idea 10 and I get a
I have a NetBeans project that I'm trying to compile manually from command-line ant
Hey! I am trying to get ant installed and actually already did following this
I'm trying to use the foreach loop in an Ant script but I get
So i am trying get 2 div-containers which both should contain centered text (Both
I am trying to get Junit work with Ant. I have come across questions
I am trying to install ANT (to build/compile Android apps) on a local Linux
Hey guys I've been trying all day to get an ant file to automatically
I'm trying to get a handle on this whole Ant buildsystem thing. I've created
I'm trying to get an ant build file to generate identical class files as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.