加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – 使用Ant执行绝对路径而不是相对路径

发布时间:2020-12-15 03:03:25 所属栏目:Java 来源:网络整理
导读:我的Ant脚本中有以下代码段.它执行得很好: exec executable="C:testfooprogramName.exe" / 但是当我尝试通过设置目录来执行它时,如下所示: exec executable="programName.exe" dir="C:testfoo" / 我明白了: Execute failed: java.io.IOException: C
我的Ant脚本中有以下代码段.它执行得很好:
<exec executable="C:testfooprogramName.exe" />

但是当我尝试通过设置目录来执行它时,如下所示:

<exec executable="programName.exe"
  dir="C:testfoo" />

我明白了:

Execute failed: java.io.IOException:
Cannot run program “programName.exe”
(in directory “C:testfoo”):
CreateProcess error=2,The system
cannot find the file specified

请帮忙!为什么单独指定目录时它不起作用?

解决方法

添加resolveexecutable属性:
<exec executable="programName.exe" 
  resolveexecutable="true"
  dir="C:testfoo" />

resolveexecutable When this
attribute is true,the name of the
executable is resolved firstly against
the project basedir and if that does
not exist,against the execution
directory if specified. On Unix
systems,if you only want to allow
execution of commands in the user’s
path,set this to false. since Ant 1.6
No,default is false

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读