fork download
  1. public class Main {
  2. public static void main(String[] args) {
  3. try {
  4. java.net.InetAddress ip = java.net.InetAddress.getLocalHost();
  5. System.out.println("Your current IP address : " + ip);
  6. String hostname = ip.getHostName();
  7. System.out.println("Your current Hostname : " + hostname);
  8. }
  9. catch(java.net.UnknownHostException e) {
  10. e.printStackTrace();
  11. }
  12. }
  13. }
Success #stdin #stdout #stderr 0.05s 4390912KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
java.net.UnknownHostException: checker: checker: Name or service not known
	at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
	at Main.main(Main.java:4)
Caused by: java.net.UnknownHostException: checker: Name or service not known
	at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
	at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
	at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
	at java.net.InetAddress.getLocalHost(InetAddress.java:1500)
	... 1 more