SUMMARY: hostname in java is always returning fully qualfied?

From: Schoep, Grant _at_ STORM <_at_>
Date: Tue May 27 2003 - 10:50:44 EDT
I figured out the problem here.

Many suggested to check out the /etc/hosts and /etc/hostname.<inteface>

Both did not have the fully qualified names. As well as uname and hostname
command all returned the non fully qualfied name.

But when looking at our nsswitch.conf file, I noticed what the issue was.

It was looking up nisplus first, and then dns, then exit. Well, for some
reason... most all of our Sun machines are not in the nisplus hosts list.
Though pretty much every other machine in existance here is. I really don't
know why the previous admin had configured it like this. So it was getting
it from DNS. I just added the culprit boxes to the nisplus database and all
is fine.

-grant






Thanks goes to the following for suggestions and answers:
Scot Needy
Matther Stier
Nigel Own
Stuart Little
John Cronin
Ben
Sean Quaint
Geroge Goffe
Gary Chambers
Alex LeDonne
Hichael Morton
Johnny Chang
Shawn Williams
Roy Rapoport
Jon Godfrey



---Original Question---
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
Received on Tue May 27 10:50:36 2003

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:11 EST