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

  • Home
  • SEARCH
  • 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 8427111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:42:35+00:00 2026-06-10T04:42:35+00:00

I am able to build java program on ant and it has been configured

  • 0

I am able to build java program on ant and it has been configured properly. However i’m wondering how would i see System.out.println / System.out.print on console using Ant ?

Note: i haven’t used ant and i am trying to explore. I hope my question is not stupid ?

Simple program

    package antTesting;
    public class Helloworld
    {

        /**
         * @param args
         */
        public static void main( String[] args )
        {
            System.out.println( " hello there !!!! " );

        }

    }

build.xml for the same

<?xml version="1.0"?>
<project name="Ant-Test" default="main" basedir=".">
  <!-- Sets variables which can later be used. -->
  <!-- The value of a property is accessed via ${} -->
  <property name="src.dir" location="src" />
  <property name="build.dir" location="build" />
  <property name="dist.dir" location="dist" />
  <property name="docs.dir" location="docs" />

  <!-- Deletes the existing build, docs and dist directory-->
  <target name="clean">
    <delete dir="${build.dir}" />
    <delete dir="${docs.dir}" />
    <delete dir="${dist.dir}" />
  </target>

  <!-- Creates the  build, docs and dist directory-->
  <target name="makedir">
    <mkdir dir="${build.dir}" />
    <mkdir dir="${docs.dir}" />
    <mkdir dir="${dist.dir}" />
  </target>

  <!-- Compiles the java code (including the usage of library for JUnit -->
  <target name="compile" depends="clean, makedir">
    <javac srcdir="${src.dir}" destdir="${build.dir}">
    </javac>

  </target>

  <!-- Creates Javadoc -->
  <target name="docs" depends="compile">
    <javadoc packagenames="src" sourcepath="${src.dir}" destdir="${docs.dir}">
      <!-- Define which files / directory should get included, we include all -->
       <fileset dir="${src.dir}">
                <include name="**" />
           </fileset>
    </javadoc>
  </target>

  <!--Creates the deployable jar file  -->
  <target name="jar" depends="compile">
    <jar destfile="${dist.dir}\de.vogella.build.test.ant.jar" basedir="${build.dir}">
      <manifest>
        <attribute name="Main-Class" value="test.Main" />
      </manifest>
    </jar>
  </target>

  <target name="main" depends="compile, jar, docs">
    <description>Main target</description>
  </target>

</project> 

when i run > ant

on CMD

Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:C:\PROGRA~2\HP\Sprinter\
bin\JAVA_S~1\classes;C:\PROGRA~2\HP\Sprinter\bin\JAVA_S~1\classes\jasmine.jar
Buildfile: C:\Users\ms025226\workspace\TestingWorld\build.xml

clean:
   [delete] Deleting directory C:\Users\ms025226\workspace\TestingWorld\build
   [delete] Deleting directory C:\Users\ms025226\workspace\TestingWorld\docs
   [delete] Deleting directory C:\Users\ms025226\workspace\TestingWorld\dist

makedir:
    [mkdir] Created dir: C:\Users\ms025226\workspace\TestingWorld\build
    [mkdir] Created dir: C:\Users\ms025226\workspace\TestingWorld\docs
    [mkdir] Created dir: C:\Users\ms025226\workspace\TestingWorld\dist

compile:
    [javac] C:\Users\ms025226\workspace\TestingWorld\build.xml:26: warning: 'inc
ludeantruntime' was not set, defaulting to build.sysclasspath=last; set to false
 for repeatable builds
    [javac] Compiling 1 source file to C:\Users\ms025226\workspace\TestingWorld\
build

jar:
      [jar] Building jar: C:\Users\ms025226\workspace\TestingWorld\dist\de.vogel
la.build.test.ant.jar

docs:
  [javadoc] Generating Javadoc
  [javadoc] Javadoc execution
  [javadoc] Loading source file C:\Users\ms025226\workspace\TestingWorld\src\Hel
loworld.java...
  [javadoc] Constructing Javadoc information...
  [javadoc] Standard Doclet version 1.6.0_31
  [javadoc] Building tree for all the packages and classes...
  [javadoc] Building index for all the packages and classes...
  [javadoc] Picked up JAVA_TOOL_OPTIONS: -agentlib:jvmhook
  [javadoc] Picked up _JAVA_OPTIONS: -Xrunjvmhook -Xbootclasspath/a:C:\PROGRA~2\
HP\Sprinter\bin\JAVA_S~1\classes;C:\PROGRA~2\HP\Sprinter\bin\JAVA_S~1\classes\ja
smine.jar
  [javadoc] Building index for all classes...

main:

BUILD SUCCESSFUL
Total time: 2 seconds

When i defined target for classpath i am receiving an error

<!-- to printoutputs -->    
  <target name="Helloworld" description="Hello world">
        <java classname="antTesting.Helloworld">
            <arg value="arg1"/>
            <arg value="arg2"/>         
        </java>
 </target>

  <target name="main" depends="compile, jar, docs, Helloworld">
    <description>Main target</description>
  </target>

ERROR:

Helloworld:
     [java] Could not find antTesting.Helloworld. Make sure you have it in your classpath
     [java]     at org.apache.tools.ant.taskdefs.ExecuteJava.execute(ExecuteJava.java:138)
     [java]     at org.apache.tools.ant.taskdefs.Java.run(Java.java:764)
     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:218)
     [java]     at org.apache.tools.ant.taskdefs.Java.executeJava(Java.java:132)
     [java]     at org.apache.tools.ant.taskdefs.Java.execute(Java.java:105)
     [java]     at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     [java]     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     [java]     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     [java]     at java.lang.reflect.Method.invoke(Method.java:597)
     [java]     at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
     [java]     at org.apache.tools.ant.Task.perform(Task.java:348)
     [java]     at org.apache.tools.ant.Target.execute(Target.java:357)
     [java]     at org.apache.tools.ant.Target.performTasks(Target.java:385)
     [java]     at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1337)
     [java]     at org.apache.tools.ant.Project.executeTarget(Project.java:1306)
     [java]     at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
     [java]     at org.eclipse.ant.internal.launching.remote.EclipseDefaultExecutor.executeTargets(EclipseDefaultExecutor.java:32)
     [java]     at org.apache.tools.ant.Project.executeTargets(Project.java:1189)
     [java]     at org.eclipse.ant.internal.launching.remote.InternalAntRunner.run(InternalAntRunner.java:423)
     [java]     at org.eclipse.ant.internal.launching.remote.InternalAntRunner.main(InternalAntRunner.java:137)
     [java] Java Result: -1
  • 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-10T04:42:37+00:00Added an answer on June 10, 2026 at 4:42 am

    If you want to execute your class from Ant, you are not specifying it anywhere, add somehting like this to your script:

    <target name="Helloworld" description="Hello world">
        <java classname="your.package.Helloworld">
            <arg value="arg1"/>
            <arg value="arg2"/>
            ...
        </java>
    </target>
    

    The elements <arg value="..."/> are passed to your main method array parameter: main( String[] args )

    Now add the target Helloworld as a dependency to other target or select it from the run options.

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

Sidebar

Related Questions

I'd like to be able to run a simple Java program when the build
I am not able to build my application via Ant build.xml file when I
Basically, I would like to be able to build a custom extractor without having
I have set JAVA_HOME = C:\Program Files\Java\jdk1.6.0_26 in user defined variables and system variables
I'm trying to build a Chinese flashcards program in Java to help myself learn
I have an ant script that compile my program, build the jar and then
I am trying to accessing dll methods in java which has been written in
I m able to build a windows service and install it. I m curious
I need to be able to build all directories up to and including the
I want to be able to build our small codebase from TeamCity and we

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.