How do I query a Whois server using the Apache Commons Net library?
Author: Deron Eriksson
Description: This Java tutorial describes how to query a Whois server using the Apache Commons Net library.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0)

Page:    1 2 >

The ApacheSW Commons NetS library has a WhoisClient class that makes it very easy to connect to a WhoisW server and query it.

The WhoisLookup class demonstrates the use of WhoisClient. We make a connection to "" using the connect() method, and then query the Whois server using the query() method with our query string. The query() method returns the results in a String, which we then display.

package test;


public class WhoisLookup {

	public static final String WHOIS_SERVER = "";
	public static final int WHOIS_PORT = 43;

	public static void main(String[] args) throws Exception {

		String nameToQuery = "";

		WhoisClient whoisClient = new WhoisClient();
		whoisClient.connect(WHOIS_SERVER, WHOIS_PORT);
		String results = whoisClient.query(nameToQuery);


(Continued on page 2)

Page:    1 2 >