How To Pass Command Line Arguments To Ant Task / Script

By Angsuman Chakraborty, Gaea News Network
Sunday, August 17, 2008

Ant is a popular, high quality Java based build and deployment tool from Apache Foundation. You can invoke Java programs in ant using the java task. Optionally you may want to pass it command line arguments. Here is how you can do it.

ant -Dclass=class.name -Dargs=”optional multiple arguments enclosed within double quotes” run

You can access it within your java task as follows:

[java fork="yes" classname="${class}" >
    ....
    [arg line="${args}"/>
[/java>

Note: Replace [ with < because stupid WordPress doesn’t display tags with angular brackets properly!

Discussion

Ali
February 9, 2010: 1:06 pm

I have a .bat file which calls a script file.I want to pass parameter in the script file.Will Pls suggest me what to do?

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :