This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Change directory using ant task Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Change directory using ant task" Watch "Change directory using ant task" New topic

Change directory using ant task

Mary Cole
Ranch Hand

Joined: Dec 02, 2000
Posts: 362
Hi all,

How do i change directory using ant .I am using and it gives Execute failed: cd: not found.

Can you pls advice?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15951

The concept of a current directory doesn't exist within Ant. You would be better off making your directory references relative to a defined property.

The immediate reason that your task failed is because "cd" wasn't locatable as an external command. Often 'cd' is built into the command shell and doesn't exist as a discrete external program.

For programs that do exist discretely, it's better to specify their full pathname. Not only does that help Ant find them, it protects you from alternative programs that have the same name - such programs may exist for several reasons, some good, some evil.

However, returning specifically to 'cd'. If 'cd' was an external command, it's not unlikely that Ant would have issued the 'cd', changed the directory for duration of that task, then reverted to its original setting. Which is one more reason why you don't want to use the 'cd' command in Ant.

Customer surveys are for companies who didn't pay proper attention to begin with.
I agree. Here's the link:
subject: Change directory using ant task
Similar Threads
Trouble launching ant exec task
White space issue in exec command.
How to use ct command with ANT in Unix Environment
New to Java
Sourcing a profile