使用Ant的命令行参数运行的程序 [英] Use Ant for running program with command line arguments

查看:207
本文介绍了使用Ant的命令行参数运行的程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序得到命令行参数。我怎样才能通过它,当我使用Ant?

My program getting command line arguments. How can I pass it when I use Ant?

推荐答案

扩展<一个href=\"http://stackoverflow.com/questions/3730880/use-ant-for-running-program-with-command-line-arguments/3730898#3730898\">Richard库克的答案。

这里的蚂蚁任务运行任何程序(包括但不限于Java程序):

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

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

下面是运行从的.jar 文件中的Java程序的任务是:

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

请务必使用 -Darg 语法;如果你跑了这一点:

Make sure to use the -Darg syntax; if you ran this:

ant run arg0 arg1

然后蚂蚁将尝试运行目标将arg0 ARG1

这篇关于使用Ant的命令行参数运行的程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆