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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:25:25+00:00 2026-06-16T09:25:25+00:00

Here is my run in my ant build file: <target name=run depends=jar> <java fork=true

  • 0

Here is my “run” in my ant build file:

<target name="run" depends="jar">
        <java fork="true" classname="${main-class}">
            <classpath>


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


            </classpath>


        </java>
    </target>

I want to run it like this:

ant run -Darg0=First.txt -Darg1=Second.txt -Darg2=Third.txt -Darg3=Fourth.txt -Darg4=Fifth.txt

What changes should i make in my “run”?

Many thanks for help!

  • 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-16T09:25:27+00:00Added an answer on June 16, 2026 at 9:25 am

    Here’s the ant task to run any program (including, but not limited to Java programs):

     <target name="run">
        <exec executable="name-of-executable-file">
          <arg value="${arg0}"/>
          <arg value="${arg1}"/>
        </exec>
      </target>
    

    Here’s the task to run a Java program from a .jar file:

      <target name="run-java">
        <java executable="path for jar">
          <arg value="${arg0}"/>
          <arg value="${arg1}"/>
        </java>
      </target>
    

    You can invoke either from the command line like this:

    ant -Darg0=Hello -Darg1=World run
    

    Updated task

    <target name="run" depends="jar">
            <java fork="true" classname="${main-class}">
                <classpath>
                 <path location="${jar.dir}/${ant.project.name}.jar"/>
                </classpath>
                <arg value="${arg0}" />
            <arg value="${arg1}" />
            </java>
        </target>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to run Junit test from my ant build.xml file. I read here
I am creating my build.xml file to build my jar with ant. All is
All Here i want to run .sh file via system call in android NDK.
Greeting, I'm trying to put some Beanshell script in my Ant build.xml file. I've
When I build the PlayN project and run the java version, it's behaviour is
i have written an ant script, which runs ok and generate the .jar file
Is there a tutorial on how to run Ant from Java? I got some
I am trying to write a build.xml file for my project. When I run
I'm mavenizing an ANT project and building the POM file. The current ANT build
I've compiled a java project into a Jar file, and am having issues running

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.