hostname in java is always returning fully qualfied?
2007-12-25 1:20:00
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>
Comments
Got something to say?
You must be logged in to post a comment.

