0 votes
in Apache by
How to Run a Java program using Apache Ant, Explain with example?

1 Answer

0 votes
by

Ant allows to run Java programs. You can specify properties which are passed as parameters to the main method of Java. The following demonstrates how to run a Java program.

<project name="Run java program" basedir="." default="default">

     <property name="outputdir.property" value="../../output/"/>
     <property name="inputdir.property" value="../../output/"/>
     <property name="classpath.property" value="${basedir}/../com.vogella.website.repository/target/repository/plugins/"/>


    <target name="default">

    <path id="runtime.path">
            <fileset dir="${classpath.property}" includes="*.jar"/>
    </path>
        <echo message = "Ant output directory: ${outputdir.property}"/>
        <echo message = "Ant input directory for tutorials: ${inputdir.property}"/>
        <echo message = "Ant classpath directory: ${classpath.property}"/>
        <java classname="com.vogella.test.Mail" fork="false" classpathref="runtime.path">
                <arg value="${outputdir.property}"/>
                <arg value="${inputdir.property}"/>
        </java>
    </target>

</project>

Related questions

0 votes
asked Nov 11, 2023 in Apache by GeorgeBell
0 votes
asked Nov 14, 2023 in Apache by GeorgeBell
...