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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:18:43+00:00 2026-06-07T08:18:43+00:00

ant bootstrap arg1 arg2 arg3 I need to echo "arg1 arg2 arg3" so that

  • 0

ant bootstrap arg1 arg2 arg3

I need to echo "arg1 arg2 arg3" so that I can call a program with those arguments

Searching the web the following should work but does not.

 <target name="bootstrap">
     <echo>${arg0} ${arg1} ${arg2} </echo>
     <!--exec executable="cmd">
        <arg value="${arg0}"/>
        <arg value="${arg1}"/>
        <arg value="${arg2}"/>
     </exec-->
 </target>

Also, any thoughts on what if the user passes in 5 args or 1 arg. I need to fail it does not not have the right number of args.

  • 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-07T08:18:46+00:00Added an answer on June 7, 2026 at 8:18 am

    No.

    You can not pass arguments that will be used inside a build file in that way. The ant bootstrap arg1 arg2 arg3 will be resolved as you are trying to call the following targets bootstrap, arg1, arg2, arg3 — and, obviously, only the target bootstrap exists.

    If you do want to pass arguments that will be used in the build file, you need to use the -DpropertyName=value format. For example:

    ant bootstrap -Darg1=value1 -Darg2=value2 -Darg3=value3
    

    For other ways, you can write embed script in the build file (like beanshell or javascript, with ant’s script support libs) to process the arguments at first. For example, you can pass the arguments in this way:

    ant bootstrap -Dargs=value1,value2,value3,...
    

    and now you have a property named args with the value “value1,value2,value3,…” (for … I mean that the user may type in more than 3 values). You can use beanshell to split the args to arg1, arg2 and arg3 by ,, and also do some checking…

    <script language="beanshell" classpathref="classpath-that-includes-the-beanshell-lib">
        String[] args = project.getProperty("args").split(",");
        project.setUserProperty("arg1", args[0].trim());
        project.setUserProperty("arg2", args[1].trim());
        project.setUserProperty("arg3", args[2].trim());
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As we do in Ant build, we can specify the Jars that we need
Using ANT , how can i make sure that directory exists before attempting to
Ant script <property environment=env> <if> <equals arg1=${env.PARA} arg2=/> <then> <property name=${env.PARA} value=abc/> <then> <if>
My ant script is, <target name=temp> <property name=argument value=xyz abc/> <echo message= & quot;${argument}&
With ant there exists the echo markup: <echo message="Hello, world"/> but it seems useless.
I have an ant script that compile my program, build the jar and then
Ant seems to be pretty bad as running interactive program. So for instance, a
My ANT build script uses a WebSphere command called createEJBStubs that produces a JAR
The Ant war task does just that - creates WEB-INF along with META-INF, depending
My ant build script starts with a java task that uses fork=true <java fork=true

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.