fork download
  1. public class Main {
  2. private static String OS = System.getProperty("os.name").toLowerCase();
  3. public static void main(String[] args) {
  4. System.out.println(OS);
  5. try {
  6. System.out.println(java.net.InetAddress.getLocalHost().getHostAddress());
  7. }
  8. catch(java.net.UnknownHostException e) {
  9. e.printStackTrace();
  10. }
  11. }
  12. }
Success #stdin #stdout #stderr 0.05s 4390912KB
stdin
Standard input is empty
stdout
linux
stderr
java.net.UnknownHostException: checker: checker: Name or service not known
	at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
	at Main.main(Main.java:6)
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