public static final String getHostName() {
		if (cachedHostName != null) {
			return cachedHostName;
		}

		// User-defined public hostname
		String name = System.getProperty("hostname");
		if (name == null || name.isEmpty()) {
			try {
				name = InetAddress.getLocalHost().getHostName();
			} catch (Exception ignored) {
				name = null;
			}
		}
		if (name == null || name.isEmpty() || name.contains("localhost")) {
			try {
				name = System.getenv().get("COMPUTERNAME");
			} catch (Exception ignored) {
				name = null;
			}
		}
		if (name == null || name.isEmpty()) {
			cachedHostName = "localhost";
		} else {
			cachedHostName = name.toLowerCase();
		}
		return cachedHostName;
	}
public static final String getHostName ( ) { if ( cachedHostName != null ) { return cachedHostName ; } String name = System . getProperty ( "hostname" ) ; if ( name == null || name . isEmpty ( ) ) { try { name = InetAddress . getLocalHost ( ) . getHostName ( ) ; } catch ( Exception ignored ) { name = null ; } } if ( name == null || name . isEmpty ( ) || name . contains ( "localhost" ) ) { try { name = System . getenv ( ) . get ( "COMPUTERNAME" ) ; } catch ( Exception ignored ) { name = null ; } } if ( name == null || name . isEmpty ( ) ) { cachedHostName = "localhost" ; } else { cachedHostName = name . toLowerCase ( ) ; } return cachedHostName ; }
--- LOCAL HOST NAME ---