Posted by bristimjet on 25-11-2013 05:38
#1
I want to print the local host name, but it always prints null .. how can I get host name ?
Java Code
String hostname = System.getenv("HOSTNAME");
System.err.println("Hostname = " + hostname);
______________________________
Online fax
Edited by bristimjet on 01-12-2013 04:27
Posted by EVA-00 on 26-11-2013 03:20
#2
Try this,
package testing;
import java.net.*;
public class Test
{
public static void main(String[] args) throws UnknownHostException
{
System.out.println(InetAddress.getLocalHost().getHostName());
}