Welcome aboard! We are happy you are here and wish you good net-raft!
package myproject;
import java.net.InetAddress;
class Main
{
public static void main(String args[]) throws Exception
{
System.out.println(InetAddress.getLocalHost());
}
}
// or try this
package myproject;
import java.net.InetAddress;
import java.net.UnknownHostException;
class Main
{
public static void main(String args[]) throws Exception
{
String hostname = "Unknown";
InetAddress addr;
addr = InetAddress.getLocalHost();
hostname = addr.getHostName();
System.out.println(hostname);
}
}
The most helpful JAVA solutions