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 8812469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:36:48+00:00 2026-06-14T03:36:48+00:00

I’m trying to following apache’s ANT tutorial: http://ant.apache.org/manual/index.html I’m currently at the JUnit portion,

  • 0

I’m trying to following apache’s ANT tutorial:

http://ant.apache.org/manual/index.html

I’m currently at the JUnit portion, but I keep getting errors related to not being able to find the junit.framework package.

I believe I’ve followed the tutorial exactly as follows – Here are the details:

—–My file structure—–

build.xml
/build
../classes
/lib
..log4j-1.2.8.jar
myManifest
/src
..HelloWorldTest.java
..log4j.properties
../oata
....HelloWorld.java

—–Sources—–

myManifest:

Main-Class: oata.HelloWorld

build.xml:

<project name ="HelloWorld" basedir="." default="main">
    <property name="src.dir" value="src" />
    <property name="build.dir" value="build" />
    <property name="classes.dir" value="${build.dir}/classes" />
    <property name="jar.dir"    value="${build.dir}/jar" />
    <property name="lib.dir"    value="lib" />

    <path id="classpath">
        <fileset dir="${lib.dir}" includes="**/*.jar" />
    </path>

    <property name="main-class" value="oata.HelloWorld" />

    <target name="clean">
        <delete dir="${build.dir}"/>
    </target>

    <target name="compile">
        <mkdir dir="${classes.dir}"/>
        <javac srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath" />
        <copy todir="${classes.dir}" >
            <fileset dir="${src.dir}" excludes="**/*.java" />
        </copy>
    </target>

    <target name="jar" depends="compile">
        <mkdir dir="${jar.dir}" />
        <jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
            <manifest>
                <attribute name="Main-Class" value="${main-class}" />
            </manifest>
        </jar>
    </target>

    <target name="run" depends="jar">
        <java fork="true" classname="${main-class}">
            <classpath>
                <path refid="classpath"/>
            <path id="application" location="${jar.dir}/${ant.project.name}.jar"/>
            </classpath>
        </java>
    </target>

    <target name="junit" depends="jar">
            <junit printsummary="yes">
                <classpath>
                    <path refid="classpath"/>
                    <path refid="application"/>
                </classpath>

                <batchtest fork="yes">
                    <fileset dir="${src.dir}" includes="*Test.java"/>
                </batchtest>
            </junit>
        </target>

    <target name="clean-build" depends="clean,jar" />

    <target name="main" depends="clean,run" />
</project>

HelloWorldTest.java:

public class HelloWorldTest extends junit.framework.TestCase {

    public void testNothing() {
    }

    public void testWillAlwaysFail() {
        fail("An error message");
    }

}

HelloWorld.java

package oata;

import org.apache.log4j.Logger;

public class HelloWorld {
    static Logger logger = Logger.getLogger(HelloWorld.class);

    public static void main(String [] args){
        logger.info("Hello World!");
    }
}

log4j.properties:

log4j.rootLogger=DEBUG, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%m%n

—Output—

 ant -verbose junit
Apache Ant(TM) version 1.8.2 compiled on June 20 2012
Trying the default build file: build.xml
Buildfile: /Users/jtyler/Projects/AntHelloWorld/build.xml
Detected Java version: 1.6 in: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Detected OS: Mac OS X
parsing buildfile /Users/jtyler/Projects/AntHelloWorld/build.xml with URI = file:/Users/jtyler/Projects/AntHelloWorld/build.xml
Project base dir set to: /Users/jtyler/Projects/AntHelloWorld
parsing buildfile jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml with URI = jar:file:/usr/share/ant/lib/ant.jar!/org/apache/tools/ant/antlib.xml from a zip file
Build sequence for target(s) `junit' is [compile, jar, junit]
Complete build sequence is [compile, jar, junit, clean, run, main, clean-build, ]

compile:
    [mkdir] Skipping /Users/jtyler/Projects/AntHelloWorld/build/classes because it already exists.
    [javac] /Users/jtyler/Projects/AntHelloWorld/build.xml:20: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] HelloWorldTest.java added as HelloWorldTest.class doesn't exist.
    [javac] /Users/jtyler/Projects/AntHelloWorld/src/log4j.properties skipped - don't know how to handle it
    [javac] oata/HelloWorld.java added as oata/HelloWorld.class doesn't exist.
    [javac] Compiling 2 source files to /Users/jtyler/Projects/AntHelloWorld/build/classes
    [javac] Using modern compiler
    [javac] Compilation arguments:
    [javac] '-d'
    [javac] '/Users/jtyler/Projects/AntHelloWorld/build/classes'
    [javac] '-classpath'
    [javac] '/Users/jtyler/Projects/AntHelloWorld/build/classes:/Users/jtyler/Projects/AntHelloWorld/lib/log4j-1.2.8.jar:/usr/share/ant/lib/ant-launcher.jar:/usr/share/ant/lib/ant-antlr.jar:/usr/share/ant/lib/ant-jmf.jar:/usr/share/ant/lib/ant-junit.jar:/usr/share/ant/lib/ant-junit4.jar:/usr/share/ant/lib/ant-swing.jar:/usr/share/ant/lib/ant-testutil.jar:/usr/share/ant/lib/ant.jar'
    [javac] '-sourcepath'
    [javac] '/Users/jtyler/Projects/AntHelloWorld/src'
    [javac] '-g:none'
    [javac] 
    [javac] The ' characters around the executable and arguments are
    [javac] not part of the command.
    [javac] Files to be compiled:
    [javac]     /Users/jtyler/Projects/AntHelloWorld/src/HelloWorldTest.java
    [javac]     /Users/jtyler/Projects/AntHelloWorld/src/oata/HelloWorld.java
    [javac] /Users/jtyler/Projects/AntHelloWorld/src/HelloWorldTest.java:1: package junit.framework does not exist
    [javac] public class HelloWorldTest extends junit.framework.TestCase {
    [javac]                                                    ^
    [javac] /Users/jtyler/Projects/AntHelloWorld/src/HelloWorldTest.java:7: cannot find symbol
    [javac] symbol  : method fail(java.lang.String)
    [javac] location: class HelloWorldTest
    [javac]         fail("An error message");
    [javac]         ^
    [javac] 2 errors

BUILD FAILED
/Users/jtyler/Projects/AntHelloWorld/build.xml:20: Compile failed; see the compiler error output for details.
    at org.apache.tools.ant.taskdefs.Javac.compile(Javac.java:1150)
    at org.apache.tools.ant.taskdefs.Javac.execute(Javac.java:912)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    at org.apache.tools.ant.Task.perform(Task.java:348)
    at org.apache.tools.ant.Target.execute(Target.java:390)
    at org.apache.tools.ant.Target.performTasks(Target.java:411)
    at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
    at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
    at org.apache.tools.ant.Main.runBuild(Main.java:809)
    at org.apache.tools.ant.Main.startAnt(Main.java:217)
    at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Total time: 0 seconds

Is there something I’m missing that’s needed to be included that was (or wasn’t) mentioned in the tutorial?

EDIT: Based on Alex’s inquiries, I tested to see if I had ant’s junit jars in my shared directories (which I do):

$ ls /usr/share/ant/lib/ant-junit*.jar
/usr/share/ant/lib/ant-junit.jar    /usr/share/ant/lib/ant-junit4.jar

I also tried to manually put ant-junit, ant-junit4.jar, and junit.jar into my project’s lib directory, with the following results (all errors) after running ant clean junit:

  • junit.jar – /Users/jtyler/Projects/AntHelloWorld/build.xml:45: Reference application not found.
  • ant-junit.jar: package junit.framework does not exist
  • ant-junit.jar and ant.junit4.jar: package junit.framework does not exist
  • ant-junit4.jar: package junit.framework does not exist

EDIT The whole error when only junit.jar is included in the lib folder and calling ant clean junit is:

$ ant clean junit
Buildfile: /Users/jtyler/Projects/AntHelloWorld/build.xml

clean:
   [delete] Deleting directory /Users/jtyler/Projects/AntHelloWorld/build

compile:
    [mkdir] Created dir: /Users/jtyler/Projects/AntHelloWorld/build/classes
    [javac] /Users/jtyler/Projects/AntHelloWorld/build.xml:20: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    [javac] Compiling 2 source files to /Users/jtyler/Projects/AntHelloWorld/build/classes
     [copy] Copying 1 file to /Users/jtyler/Projects/AntHelloWorld/build/classes

jar:
    [mkdir] Created dir: /Users/jtyler/Projects/AntHelloWorld/build/jar
      [jar] Building jar: /Users/jtyler/Projects/AntHelloWorld/build/jar/HelloWorld.jar

junit:

BUILD FAILED
/Users/jtyler/Projects/AntHelloWorld/build.xml:45: Reference application not found.
  • 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-14T03:36:50+00:00Added an answer on June 14, 2026 at 3:36 am

    On top of including the junit.jar file within my lib dir, I added the following line to my build.xml file right above the junit task declaration:

    <path id="application" location="${jar.dir}/${ant.project.name}.jar"/>
    

    which is a copy of the ‘application’ path id declaration within the ‘run’ task definition.

    The application builds successfully, and I get the following output with ant junit (test failure is expected):

    ant junit
    Buildfile: /Users/jtyler/Projects/AntHelloWorld/build.xml
    
    compile:
        [javac] /Users/jtyler/Projects/AntHelloWorld/build.xml:20: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
    
    jar:
    
    junit:
        [junit] Running HelloWorldTest
        [junit] Tests run: 2, Failures: 1, Errors: 0, Time elapsed: 0.001 sec
        [junit] Test HelloWorldTest FAILED
    
    BUILD SUCCESSFUL
    Total time: 1 second
    

    Comments the following questions would be greatly appreciated:

    1. Is the fact I actually needed to include the junit.jar file in my lib folder something I should be concerned about? I would assume this is not necessary if ant’s tutorial explicitly states “Because Ant has a built-in JUnit 3.8.2 you could start directly using it.”

    2. Is the fact I needed to define the ‘application’ path id outside of the run task definition a typo within the apache ant tutorial? Or are there other things I missed or should consider?

    Thanks to all those that helped.

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

Sidebar

Related Questions

I would like my Web page http://www.gmarks.org/math_in_e-mail.txt on my Apache 2.2.14 server to display
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want to count how many characters a certain string has in PHP, but
I am trying to render a haml file in a javascript response like so:

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.