Access the remote server from ANT

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?
Who is Participating?
ozlevanonConnect With a Mentor Commented:
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"/>
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.