This is a simple Java Example which uses Apache Commons Net library to pull all Whois data.
The WhoisClient
class implements the client side of the Internet Whois Protocol defined in RFC 954
. To query a host you create a WhoisClient instance, connect to the host, query the host, and finally disconnect from the host. If the whois service you want to query is on a non-standard port, connect to the host at that port.
You need below maven dependency in your pom.xml
file.
<dependency> <groupId>commons-net</groupId> <artifactId>commons-net</artifactId> <version>3.9.0</version> </dependency>
To include this dependency in your project, add the above code to your pom.xml
file in the dependencies
section. After that, run the command mvn install
to download and install the dependency.
CrunchifyWhoisExample.java
package crunchify.com.tutorials; import org.apache.commons.net.whois.WhoisClient; import java.io.IOException; import java.net.SocketException; /** * @author Crunchify.com * How to Find Information On Any Domain Name and Whois details for any given Website? */ public class CrunchifyWhoisExample { public static void main(String[] args) { CrunchifyWhoisExample obj = new CrunchifyWhoisExample(); System.out.println(obj.crunchifyWhois("Crunchify.com")); System.out.println("\nTest Finished.."); } public String crunchifyWhois(String domainName) { StringBuilder whoisResult = new StringBuilder(""); WhoisClient crunchifyWhois = new WhoisClient(); try { // The WhoisClient class implements the client side of the Internet // Whois Protocol defined in RFC 954. To query a host you create a // WhoisClient instance, connect to the host, query the host, and // finally disconnect from the host. If the whois service you want // to query is on a non-standard port, connect to the host at that // port. crunchifyWhois.connect(WhoisClient.DEFAULT_HOST); String whoisData = crunchifyWhois.query("=" + domainName); // append(): Appends the specified string to this character sequence. // The characters of the String argument are appended, in order, increasing // the length of this sequence by the length of the argument. // If str is null, then the four characters "null" are appended. whoisResult.append(whoisData); crunchifyWhois.disconnect(); } catch (SocketException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } return whoisResult.toString(); } }
Just run above program as Java Application and you will see result as below.
IntelliJ IDEA console result
Domain Name: CRUNCHIFY.COM Registry Domain ID: 1791810476_DOMAIN_COM-VRSN Registrar WHOIS Server: whois.google.com Registrar URL: http://domains.google.com Updated Date: 2023-01-17T15:13:47Z Creation Date: 2013-04-06T18:34:53Z Registry Expiry Date: 2025-04-06T18:34:53Z Registrar: Google LLC Registrar IANA ID: 895 Registrar Abuse Contact Email: registrar-abuse@google.com Registrar Abuse Contact Phone: +1.8772376466 Domain Status: clientTransferProhibited https://icann.org/epp#clientTransferProhibited Name Server: NS-CLOUD-C1.GOOGLEDOMAINS.COM Name Server: NS-CLOUD-C2.GOOGLEDOMAINS.COM Name Server: NS-CLOUD-C3.GOOGLEDOMAINS.COM Name Server: NS-CLOUD-C4.GOOGLEDOMAINS.COM DNSSEC: signedDelegation DNSSEC DS Data: 42067 8 2 2ED1CB01B2352E0DE283DB380F818CEA6E67926D285BC31B3EF41031A6E1008A URL of the ICANN Whois Inaccuracy Complaint Form: https://www.icann.org/wicf/ >>> Last update of whois database: 2023-02-02T03:59:11Z <<< For more information on Whois status codes, please visit https://icann.org/epp NOTICE: The expiration date displayed in this record is the date the registrar's sponsorship of the domain name registration in the registry is currently set to expire. This date does not necessarily reflect the expiration date of the domain name registrant's agreement with the sponsoring registrar. Users may consult the sponsoring registrar's Whois database to view the registrar's reported date of expiration for this registration. TERMS OF USE: You are not authorized to access or query our Whois database through the use of electronic processes that are high-volume and automated except as reasonably necessary to register domain names or modify existing registrations; the Data in VeriSign Global Registry Services' ("VeriSign") Whois database is provided by VeriSign for information purposes only, and to assist persons in obtaining information about or related to a domain name registration record. VeriSign does not guarantee its accuracy. By submitting a Whois query, you agree to abide by the following terms of use: You agree that you may use this Data only for lawful purposes and that under no circumstances will you use this Data to: (1) allow, enable, or otherwise support the transmission of mass unsolicited, commercial advertising or solicitations via e-mail, telephone, or facsimile; or (2) enable high volume, automated, electronic processes that apply to VeriSign (or its computer systems). The compilation, repackaging, dissemination or other use of this Data is expressly prohibited without the prior written consent of VeriSign. You agree not to use electronic processes that are automated and high-volume to access or query the Whois database except as reasonably necessary to register domain names or modify existing registrations. VeriSign reserves the right to restrict your access to the Whois database in its sole discretion to ensure operational stability. VeriSign may restrict or terminate your access to the Whois database for failure to abide by these terms of use. VeriSign reserves the right to modify these terms at any time. The Registry database contains ONLY .COM, .NET, .EDU domains and Registrars. Test Finished.. Process finished with exit code 0
Let me know if you face any issue running above Java program.