hostname in java is always returning fully qualfied?

From: Schoep, Grant @ STORM (@)
Date: Fri May 23 2003 - 17:55:04 EDT


All,
        Developers have been moaning about a few Solaris 2.8 boxes here for
some time and they finally have me convinced that it is a Solaris(not a
Java) issue.

Basically, in java code there is a way to return the hostname of the
machine. Well in this case, two of our Solaris machines are always returning
the fully qualified name of our machine, instead of just the hostname.

They've shown me how they have ran it on about 200 machines(Windows, Linux,
Solaris, IRIX, Tru64) but just two machines, two of my many Solaris machines
are returning the fully qualified name instead of just the hostname.

Meaning its returing 'theMachine.myaddress.com' instead of just 'theMachine'

Any one have a clue as to how these Solaris machines could be configured
differently?

If you want to run/compile the code, it is below. We are using Sun's SDK 1.4
and JRE 1.4 for running it.

<begin code>
import java.net.InetAddress;
import java.net.UnknownHostException;

class test
{
    public static void main(String args[])
    {
        try
        {
            String hostname = InetAddress.getLocalHost().getHostName();
            System.out.println("HostName is: " + hostname);
        }
        catch(Exception ex)
        {
            System.out.println("Could Not Get hostname");
        }
        
    }
}
<end code>
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:26:28 EDT