This week's book giveaway is in the JDBC forum.
We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line!
See this thread for details.
The moose likes Ant, Maven and Other Build Tools and the fly likes Ant scp task giving Error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Ant scp task giving Error" Watch "Ant scp task giving Error" New topic

Ant scp task giving Error

sasank ch

Joined: Nov 07, 2007
Posts: 25
Hi All,

I have one requirement, to copy the local files to remote system.
I have done the following steps:

download the jsch-0.1.40.jar;
E:\AntTest>set path=E:\AntTest\jsch-0.1.40.jar;%path%;
E:\AntTest>set classpath=E:\AntTest\jsch-0.1.40;%classpath%;

E:\AntTest>ant copyFileToRemote
Buildfile: build.xml

[echo] 2222222222 copyFileToRemote Examples:::::::::::::

E:\AntTest\build.xml:28: Could not create task or type of type: scp.
Ant could not find the task or a class this task relies upon.
This is common and has a number of causes; the usual
solutions are to read the manual pages then download and
install needed JAR files, or fix the build file:
- You have misspelt 'scp'.
Fix: check your spelling.
- The task needs an external JAR file to execute
and this is not found at the right place in the classpath.
Fix: check the documentation for dependencies.
Fix: declare the task.
- The task is an Ant optional task and the JAR file and/or libraries
implementing the functionality were not found at the time you
yourself built your installation of Ant from the Ant sources.
Fix: Look in the ANT_HOME/lib for the 'ant-' JAR corresponding to the
task and make sure it contains more than merely a META-INF/MANIFEST.MF.
If all it contains is the manifest, then rebuild Ant with the needed
libraries present in ${ant.home}/lib/optional/ , or alternatively,
download a pre-built release version from
- The build file was written for a later version of Ant
Fix: upgrade to at least the latest release version of Ant
- The task is not an Ant core or optional task
and needs to be declared using <taskdef>.
- You are attempting to use a task defined using
<presetdef> or <macrodef> but have spelt wrong or not
defined it at the point of use

The Build file as follows:

<project name="ImportedBuild" default="all">
<target name="copyFileToRemote">
<echo>2222222222 copyFileToRemote Examples:::::::::::::</echo>
<scp file="sample.txt" todir="${username}:${password}@${hostname}:/shared"/>

Could you please give me any solution to resolve this issus and provide any examples . It would be great help to me.

Amir Iqbal
Ranch Hand

Joined: Jun 23, 2007
Posts: 97
Dear Sasank,

There are two possibilities:


the "jsch-0.1.40.jar" file is not working. means i also face this problem. that i do have this jar in my lib folder but still its not working.
so try to seprately download a newer jsc.jar and then place it in your classpath.


you said you need the sample code so here is my sample code :


i am Java +ve Now !
sasank ch

Joined: Nov 07, 2007
Posts: 25
Dear Amir,

Thank you for your Replay.

Could you please let me know, Where will i get the antlib.xml.

I think, because of the xml file missing, I am getting the following error:
Could not create task or type of type: trycatch.

<taskdef resource="net/sf/antcontrib/antlib.xml" />

Misha Ver
Ranch Hand

Joined: Mar 03, 2008
Posts: 470
You need ant-contrib-version.jar
I agree. Here's the link:
subject: Ant scp task giving Error
It's not a secret anymore!