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

前端之家收集整理的这篇文章主要介绍了java – 使用Ant执行绝对路径而不是相对路径前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我的Ant脚本中有以下代码段.它执行得很好:
<exec executable="C:\test\foo\programName.exe" />

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

<exec executable="programName.exe"
  dir="C:\test\foo\" />

我明白了:

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

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

解决方法

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

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

原文链接:https://www.f2er.com/java/128650.html

猜你在找的Java相关文章