DEV Community

slxca
slxca

Posted on

Why WHOIS Is Dead in Modern Java (And How to Check Domains with RDAP)

If you have ever needed to programmatically check domain registration status or look up authoritative nameservers in Java, you likely ran into the same painful legacy protocol: WHOIS.

For decades, checking a domain meant opening a raw TCP socket on port 43, sending a query, and parsing completely unstructured plain-text responses. Every domain registry formats their output differently, meaning your code breaks the moment a registrar updates their whitespace, disclaimer, or field naming.

Fortunately, ICANN designated WHOIS as deprecated and introduced RDAP (Registration Data Access Protocol) as its official successor.

Here is why RDAP is superior and how to use it cleanly in Java without framework bloat.


Why RDAP Changes Everything

RDAP modernizes registry lookups by replacing ad-hoc text streams with established web standards:

  • Standard HTTP(S): Queries run over standard port 443 using simple GET requests. No firewall issues blocking port 43.
  • Strict JSON Schema: Responses adhere to standardized JSON formats (defined in RFC 9083), eliminating brittle regex parsing.
  • Standardized Status Codes: Determining whether a domain is taken is straightforward:
    • HTTP 200 OK = Registered / Exists
    • HTTP 404 Not Found = Available
  • Universal Discovery via IANA: You do not need to hardcode WHOIS server hostnames. IANA maintains a centralized bootstrap registry mapping TLDs to their authoritative RDAP endpoints.

The Problem with Java RDAP Libraries

While RDAP itself is a massive upgrade, the Java ecosystem historically lacked a simple, focused client:

  1. Abandoned projects: Several early RDAP implementations have not received updates in years.
  2. RFC Overkill: Many attempts try to implement every single RFC extension (complex vCard parsers, ASN allocations, IPv6 subnet blocks), turning a simple domain check into a heavy multi-megabyte dependency.
  3. Manual Bootstrap Routing: Writing the logic to query IANA bootstrap files, cache them thread-safely, and handle edge-case ccTLDs requires non-trivial boilerplate.

To solve this, I built rdap-java—a lightweight (~5 KB) client built on top of native Java 11+ HttpClient and basic JSON parsing.


Quick Implementation Guide

1. Add Dependency

Available directly on Maven Central:

Maven:

<dependency>
    <groupId>com.slxca</groupId>
    <artifactId>rdap-java</artifactId>
    <version>1.0.0</version>
</dependency>

Enter fullscreen mode Exit fullscreen mode

Gradle:

implementation 'com.slxca:rdap-java:1.0.0'

Enter fullscreen mode Exit fullscreen mode

2. Check Domain Availability

Checking if a domain is registered takes just a few lines:

import com.slxca.rdap.RDAPClient;
import com.slxca.rdap.RDAPResult;
import com.slxca.rdap.RDAPException;

public class DomainService {
    public static void main(String[] args) {
        RDAPClient client = new RDAPClient();

        try {
            RDAPResult result = client.checkDomain("github.com");

            if (result.isRegistered()) {
                System.out.println(result.getDomain() + " is already taken.");
                System.out.println("Queried Endpoint: " + result.getServerUrl());
            } else {
                System.out.println(result.getDomain() + " is available!");
            }
        } catch (RDAPException e) {
            System.err.println("Lookup failed: " + e.getMessage());
        }
    }
}

Enter fullscreen mode Exit fullscreen mode

3. Inspect Nameservers

If you are validating DNS setup or migration pipelines, you can extract authoritative nameservers directly from the parsed response:

RDAPResult result = client.checkDomain("cloudflare.com");

if (result.isRegistered()) {
    System.out.println("Authoritative Nameservers:");
    for (String ns : result.getNameservers()) {
        System.out.println(" -> " + ns);
    }
}

Enter fullscreen mode Exit fullscreen mode

Handling Fallbacks & Custom Registries

Most major gTLDs (.com, .net, .org) and newer extensions are automatically resolved via the IANA bootstrap registry.

However, some ccTLDs (such as .de, .ch, or .nl) operate their own RDAP services outside the centralized IANA bootstrap list. rdap-java comes with curated built-in fallbacks for these registries, and also allows manual overrides for private or internal registries:

// Register or override a custom endpoint at runtime
client.registerServer("customtld", "[https://rdap.example-registry.net/rdap/](https://rdap.example-registry.net/rdap/)");
RDAPResult result = client.checkDomain("app.customtld");

Enter fullscreen mode Exit fullscreen mode

Summary

If your Java application still relies on socket connections to port 43 or parsing raw WHOIS text files, migrating to RDAP is long overdue.

Feedback, edge-case TLD reports, and contributions are always welcome!

Top comments (0)