1

I tried

val cmd = sys.process.Process(Seq("C:\apache-ant-1.9.3\bin\ant", "everythingNoJunit"), new java.io.File(scriptDir))

cmd.lines

and got this error:

CreateProcess error=193, %1 is not a valid Win32 application

How do I run the ant script from within scala app?

1
  • Can you run ANY command? If you start with something simple, such as the examples in the documentation, you can then mutate it step by step into what you want. Commented Apr 16, 2014 at 15:27

1 Answer 1

1

The basic answer is that your should be using "ant.bat" instead of "ant" on a windows machine as in this answer

In addition to that, I would suggest using a non-windows styled path so you don't have to escape the backslashes:

val cmd = sys.process.Process(Seq("/apache-ant-1.9.3/bin/ant.bat", "everythingNoJunit"), new java.io.File(scriptDir))

Using this approach, I'm able to run an an ant target successfully when my scala application is also in "c:".

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks also for the tip on backslashes!
Glad it worked for you. I had fun starting a web server from within a Scala application in Eclipse and seeing the messages in the console ( I used cmd.run instead ).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.