Win a copy of 97 Things Every Java Programmer Should Know this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Ant scp task giving Error

Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Ranch Hand
Posts: 97
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 :

sasank ch
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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" />

Ranch Hand
Posts: 470
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need ant-contrib-version.jar
Hey, sticks and stones baby. And maybe a wee mention of my stuff:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic