IP Finder in Java with Source Code

Here is a simple Java program that can be used to find the IP address of a given host name:

import java.net.*;

public class IPFinder {
    public static void main(String[] args) {
        if (args.length != 1) {
            System.err.println("Usage: java IPFinder <hostname>");

        try {
            InetAddress address = InetAddress.getByName(args[0]);
            System.out.println("IP Address: " + address.getHostAddress());
        } catch (UnknownHostException e) {
            System.err.println("Unable to resolve hostname: " + args[0]);

This program takes a single command line argument, which is the host name to lookup. It then uses the InetAddress.getByName method to get the IP address of the host, and prints it out to the console.

Here is an example of how to run the program:

$ java IPFinder google.com
IP Address:

Note that this program assumes that the host name is valid and can be resolved to an IP address. If the host name is invalid or cannot be resolved, the program will throw an UnknownHostException.