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
how to get the minimum value from array using java ?JAVA
Click to see more ...
1K
49
how to create lower case using java ?JAVA
Click to see more ...
904
41
get userdomain using java JAVA
Click to see more ...
721
37
how to get the values from an array using java ?JAVA
Click to see more ...
615
32
how to create the replace function of special characters using java ?JAVA
Click to see more ...
453
31
how to get the second value from an array using java ?JAVA
Click to see more ...
432
19
how to create upper case using java ?JAVA
Click to see more ...
364
17
How to read a key on the keyboard using java ?JAVA
Click to see more ...
552
16
how to get the maximum value from array using java ?JAVA
Click to see more ...
374
13
how to create replace function using java ?JAVA
Click to see more ...
321
12