Access the remote server from ANT

czutshi used Ask the Experts™
We need to move all latest java files from local machine to server using ANT.
How do we write buil.xml file?
Can someone please help us?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
That depends on what kind of access you have to the  server machine. If you have an FTP server on the remote machine, you can use an FTP task (
If you access the remote machine using SSH telnet, you can use SCP, which does a secure copy over SSH (

Here a short snippet of the scp task (replace the ${} parts with the actual values). Note that if you do use SCP task you'll need ant-jsch.jar in your classpath (see

<scp todir="${scp.user}@${}:${}" password="${scp.password}"
                  <fileset dir="${base.dir}/src" includes="**/*.java"/>

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial