Apache Commons Net
Apache Commons Net™ library implements the client side of many basic
Internet protocols. The purpose of the library is to provide
fundamental protocol access, not higher-level
abstractions. Therefore, some of the design violates
object-oriented design principles. Our philosophy is to make the
global functionality of a protocol accessible (e.g., TFTP send
file and receive file) when possible, but also provide access to
the fundamental protocols where applicable so that the programmer
may construct his own custom implementations (e.g, the TFTP
packet classes and the TFTP packet send and receive methods are
Supported protocols include:
- FTP over HTTP (experimental)
- Time (rdate) and Daytime
Apache Jakarta Commons Net started as a commercial Java library called
NetComponents, originally developed by ORO, Inc. in the early
days of Java. After its 1.3.8 release in 1998, the source code was
donated to the Apache Software Foundation and made available under
the Apache License. Since then, many programmers have contributed
to the continued development of Jakarta Commons Net. The current
version numbering scheme bears no relation to the old. In other
words, Jakarta Commons Net 1.0 succeeded and supplanted
Apache Jakarta Commons is now an independent project and is called Apache Commons.
Commons NET includes several working sample applications that you can use.
Source files are included in the source (and binary) archives, and a compiled jar is provided.
To use one of the sample applications, ensure that the example and main jars are both in the same directory.
Then run the class as per the following example:
java -jar [path/]commons-net-examples-3.1.jar FTPClientExample [parameters]
This uses the helper application which supports shorthand class names.
Alternatively, ensure that the example and main jars are on the classpath.
Then invoke the class directly, for example:
java -cp commons-net-examples-3.1.jar;commons-net-3.1.jar examples/ftp/FTPClientExample [parameters]
FTP (package: examples/ftp)
demonstrates file download and upload, LIST, MLST etc over FTP(S) and FTP over HTTP
This program arranges a server to server file transfer that transfers a file from host1 to host2.
This is an example of a simple Java tftp client
MAIL (package: examples/mail)
This is an example program demonstrating how to use the IMAP[S]Client class.
This is an example program demonstrating how to use the POP3[S]Client class.
This is an example program demonstrating how to use the SMTP[S]Client class.
NNTP (package: examples/nntp)
Simple class showing one way to read an article header and body.
Simple class showing some of the extended commands (AUTH, XOVER, LIST ACTIVE)
This is a simple example using the NNTP package to approximate the
Unix newsgroups command. It connects to the specified news
server and issues fetches the list of newsgroups stored by the server.
On servers that store a lot of newsgroups, this command can take a very
long time (listing upwards of 30,000 groups).
Sample program demonstrating the use of article iteration and threading.
This is an example program using the NNTP package to post an article to the specified newsgroup(s).
It prompts you for header information and a filename to post.
NTP (package: examples/ntp)
This is an example program demonstrating how to use the NTPUDPClient
class. This program sends a Datagram client request packet to a
Network time Protocol (NTP) service port on a specified server,
retrieves the time, and prints it to standard output along with
the fields from the NTP message header (e.g. stratum level, reference id,
poll interval, root delay, mode, ...)
This is an example program demonstrating how to use the TimeTCPClient
and TimeUDPClient classes.
This program connects to the default time service port of a
specified server, retrieves the time, and prints it to standard output.
TELNET (package: examples/telnet)
This is a simple example of use of TelnetClient.
This is an example of a trivial use of the TelnetClient class.
It connects to the weather server at the University of Michigan,
um-weather.sprl.umich.edu port 3000, and allows the user to interact
with the server via standard input.
Unix utilities (package: examples/unix)
This is a simple example of use of chargen.
This is a simple example of use of daytime.
This is a simple example of use of echo.
This is a simple example of use of finger.
This is a simple example of use of fwhois.
This is a simple example of use of rdate.
This is a simple example of use of rexec.
This is a simple example of use of rlogin.
This is a simple example of use of rshell.
For more info, see the JavaDoc, or look at some of the following articles: