Java FTP client libraries reviewed
Learn how the available libraries stack up against each other
By Jean-pierre Norguet, JavaWorld.com, 04/04/03
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Let's imagine a situation where we want to write a pure Java application that must download files from a remote computer running
an FTP server. We also want to filter downloads on the basis of remote file information like name, date, or size.
Although it is possible, and maybe fun, to write a protocol handler for FTP from scratch, doing so is also hard, long, and
potentially risky. Since we'd rather not spend the time, effort, or money writing a handler on our own, we prefer instead
reusing an existing software component. And plenty of libraries are available on the World Wide Web. With an FTP client library,
downloading a file can be written in Java as simply as:
FTPClient ftpClient = new FTPClient();
ftpClient.connect("ftp.foo.com", "user01", "pass1234");
ftpClient.download("C:\\Temp\\", "README.txt");
// Eventually other operations here ...
ftpClient.disconnect();
Looking for a quality Java FTP client library that matches our needs is not as simple as it seems; it can be quite painful.
It takes some time to find a Java FTP client library. Then, after we find all the existing libraries, which one do we select?
Each library addresses different needs. The libraries are unequal in quality, and their designs differ fundamentally. Each
offers a different set of features and uses different types of jargon to describe them.
Thus, evaluating and comparing FTP client libraries can prove difficult and confusing. Reusing existing components is a commendable
process, but in this case, starting out can be discouraging. And this is a shame: after choosing a good FTP library, the rest
is routine.
This article aims to make that selection process short, easy, and worthwhile. I first list all available FTP client libraries.
Then I define and describe a list of relevant criteria that the libraries should address in some way. Finally, I present an
overview matrix that gives a quick view of how the libraries stack up against each other. All this information provides everything
we need to make a fast, reliable, and long-lasting decision.
FTP support in JDK
The reference specification for FTP is Request for Comments: 959 (RFC959). Sun Microsystems provides an RFC959 implementation
in the JDK, but it is internal, undocumented, and no source is provided. While RFC959 lies in the shadows, it is actually
the back end of a public interface implementing RFC1738, the URL specification, as illustrated in Figure 1.

Figure 1. FTP support in JDK. Click on thumbnail to view full-size image.
An implementation of RFC1738 is offered as standard in the JDK. It does a reasonable job for basic FTP transfer operations.
It is public and documented, and source code is provided. To use it, we write the following:
URL url = new URL("ftp://user01:pass1234@ftp.foo.com/README.txt;type=i");
URLConnection urlc = url.openConnection();
InputStream is = urlc.getInputStream(); // To download
OutputStream os = urlc.getOutputStream(); // To upload
FTP client support in JDK strictly follows the standard recommendation, but it has several downsides:
- Digg
- Reddit
- SlashDot
- Stumble
- del.icio.us
- Technorati
- dzone
Resources
- The Java FTP API standardization project homepage
http://www.alternatifs.eu/jip/cs/java-ftp-api/jfas13n.html
- Learn more about the Java Community Process
http://www.jcp.org/
- The IETF official Website
http://www.ietf.org/
- RFC959 (FTP)
http://www.ietf.org/rfc/rfc0959.txt
- RFC1579
http://www.ietf.org/rfc/rfc1579.txt
- RFC1738 (URL)
http://www.ietf.org/rfc/rfc1738.txt
- RFC1928 (Socks 5)
http://www.ietf.org/rfc/rfc1928.txt
- Some complete and clear explanations about Socks
http://www.socks.permeo.com/
- Hummingbird Socks
http://www.hummingbird.com/products/nc/socks/
- Learn more about the JavaBeans component architecture
http://java.sun.com/products/javabeans/
- Sun suggests commendable Java coding conventions
http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
- "Why Developers Should Not Write Programs That Call 'Sun' Packages" (Sun Microsystems, 1996)
http://java.sun.com/products/jdk/faq/faq-sun-packages.html
- A short overview of the Façade pattern in Java
http://www.cs.ucsb.edu/~cappello/50/lectures/patterns/Facade.html
- Learn more about patterns in Java, including the Façade patternPatterns in Java, Volume 1, Second Edition, Mark Grand (John Wiley & Sons, 2002; ISBN 0471227293)
http://www.amazon.com/exec/obidos/ASIN/0471227293/javaworld
- The bible about patterns in other languages, including the Façade patternDesign Patterns, Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, (Addison-Wesley, 1995; ISBN 0201633612)
http://www.amazon.com/exec/obidos/ASIN/0201633612/javaworld
- The Globus Toolkit Public License
http://www.globus.org/toolkit/download/license.html
- Learn more about GridFTP
http://www.globus.org/datagrid/gridftp.html
- iNet Factory, JScape
http://www.jscape.com/inetfactory/
- IP*Works, /n software
http://www.nsoftware.com/products/showprod.aspx?part=IPJ5-V
- Java FTP Client Library, Enterprise Distributed Technologies
http://www.enterprisedt.com/downloads/ftp.html
- FTP Bean Suite, IBM alphaWorks
http://www.alphaworks.ibm.com/alphabeans/ftp/
- JFtp, SourceForge
https://sourceforge.net/projects/j-ftp/
- Jakarta Commons/Net, the Jakarta Project
http://jakarta.apache.org/commons/net/
- JNetBeans, JavaShop
http://www.java-shop.com/
- Sun FTP API
http://forum.java.sun.com/thread.jsp?thread=217004&forum=54&message=752443
- JavaFTP API, Florent Cueto
http://cqs.dyndns.org:81/javaftp/
- jFTP, Bea Petrovicova
http://www.geocities.com/beapetrovicova/
- Java CoG Kit, the Globus Project
http://www.globus.org/cog/java
- Savarese NetComponents
http://www.savarese.org/java/index.html
- Jean-Pierre Norguet also authored Websphere Version 4 Application Development Handbook with Ueli Wahli, Alex Matthews, Paula Coll Lapido, Paula Call Lapido (Prentice Hall PTR, 2002; ISBN 0130092258)
http://www.amazon.com/exec/obidos/ASIN/0130092258/javaworld
- Browse JavaWorld's Product Reviews index page
http://www.javaworld.com/news-reviews/jw-nr-product-reviews.shtml
- Speak out in the JavaWorld Forum
http://forums.devworld.com/webx?13@@.ee6b802
- Sign up for JavaWorld's free weekly email newsletters
http://www.javaworld.com/subscribe
- You'll find a wealth of IT-related articles from our sister publications at IDG.net
Zehon does have support for SCPBy Anonymous on September 28, 2009, 12:30 amZehon does have support for SCP, please look at these samples. http://zehon.com/SFTP_samples.htm
Reply | Read entire comment
But Zehon = No SCPBy Anonymous on September 18, 2009, 11:50 amZehon is great for SFTP but it does not appear to support SCP.
Reply | Read entire comment
AndroidBy Anonymous on August 8, 2009, 12:17 amHow would I go about doing this in Android?
Reply | Read entire comment
Wonderful, found an easier APIBy skippy on July 15, 2009, 8:09 pmI found this FTP API at http://www.zehon.com it is much easier to use.
Reply | Read entire comment
Very interesting By Anonymous on June 25, 2009, 5:00 pmVery Interesting article on this topic
Reply | Read entire comment
View all comments