Pages Navigation Menu

Coding is much easier than you think

Getting Hostname from IP Address

Getting Hostname from IP Address

In this Tutorial, I will discuss about retrieving Hostname from IP Address using Java.


The below java code is used to Getting Hostname from IP Address

package com.simplecode;

import java.util.Scanner;

public class Hostname {

	public static void main(String[] arg) {
		Scanner scanIn = new Scanner(;
		String IpAddress = scanIn.nextLine();
		try {
			InetAddress addresses = InetAddress.getByName(IpAddress);

			String hostName = addresses.getHostName();


        catch (UnknownHostException e) {
             System.out.println("Could not resolve IP Address to Hostname. Host Unknown !");

Download It €- IpAddress


About Mohaideen Jamil

I'm a Full stack developer of IT exp in J2EE, AngularJs, MicroServices, Docker, Spring (Boot, MVC, Cloud), Bluemix, DevOps. Follow me on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.

%d bloggers like this: