CodesJava

Easy learning with example program codes

Get system hostname in java


Get system hostname in java

package com.codesjava;
 
import java.net.InetAddress;
 
public class NetworkingTest {
  public static void main(String args[]){
	try {
		InetAddress myHost = InetAddress.getLocalHost();
	        System.out.println(myHost.getHostName());
        } catch(Exception e) {
            e.printStackTrace();
        }
  }
}

Output

INDEL-L-28V8JC2
Please follow and like us:


Copyright © 2019 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki