Home Ask Login Register

Developers Planet

Your answer is one click away!

krishv February 2016

Include commons-net.jar at the custom location instead of ant install location

I am using ftp task from ant. For ftp to work, I need commons-net.jar as dependency at

ANT_HOME/lib folder.

As best practice, I am following the folder structure to keep all external folders under customized External Jars folder. Is there a way to keep commons-net.jar at customized folder instead of

ANT_HOME/lib folder?


Mark O'Connor February 2016

Another option is to place plugin jars in the "$HOME/.ant/lib" directory.

You can automate the install of your dependent jars as follows:

<project name="demo" default="build">

   <available classname="org.apache.commons.net.ftp.FTP" property="ftp.installed"/>

   <target name="init" unless="ftp.installed">
      <mkdir dir="${user.home}/.ant/lib"/>
      <get dest="${user.home}/.ant/lib/commons-net.jar" src="http://search.maven.org/remotecontent?filepath=commons-net/commons-net/3.3/commons-net-3.3.jar"/>
      <get dest="${user.home}/.ant/lib/oro.jar" src="http://search.maven.org/remotecontent?filepath=oro/oro/2.0.8/oro-2.0.8.jar"/>
      <fail message="FTP task installed. Run ANT again"/>

   <target name="build" depends="init">
      <ftp server="ftp.apache.org" userid="anonymous" password="me@myorg.com">
         <fileset dir="htdocs/manual"/>


Post Status

Asked in February 2016
Viewed 1,155 times
Voted 11
Answered 1 times


Leave an answer

Quote of the day: live life