Perform Network Lookup with the InetAddress class
import java.net.InetAddress; public class Main { public static void main(String[] args) throws Exception{ InetAddress inetHost = InetAddress.getByName("www.google.com"); String hostName = inetHost.getHostName(); System.out.println(hostName); System.out.println(inetHost.getHostAddress()); } }