开发者

running build.xml from java project

开发者 https://www.devze.com 2023-03-20 02:52 出处:网络
I am trying to run ant script from java project which, in turn, I have to make it as excutable jar file

I am trying to run ant script from java project which, in turn, I have to make it as excutable jar file here is the way I have done:

Runtime rt = Runtime.getRuntime();
rt.exec("cmd /c start ant.bat  -buildfile D:\\ant\\trail\\build.xml")

But I don't want to give full path for build.xml. Instead, I want it to take from current source directory.

I tried something like this

rt.exec("cmd /c start ant.bat  -buildfile .\build.xml");

but I get an error showing that cannot find build.开发者_JAVA技巧xml, build failed


Relative directory in java program doesn't start from the src folder, but from the projects (in Eclipse) or the jar folder. Make sure you have the file in the correct path. Also, don't forget to escape the slash:

rt.exec("cmd /c start ant.bat  -buildfile .\\build.xml");
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号