Prueba esto (sacado de):
http://stackoverflow.com/questions/4...me-is-64-chars
try {
// Replace eth0 with your interface name
NetworkInterface i = NetworkInterface.getByName("eth0");
if (i != null) {
Enumeration<InetAddress> iplist = i.getInetAddresses();
InetAddress addr = null;
while (iplist.hasMoreElements()) {
InetAddress ad = iplist.nextElement();
byte bs[] = ad.getAddress();
if (bs.length == 4 && bs[0] != 127) {
addr = ad;
// You could also display the host name here, to
// see the whole list, and remove the break.
break;
}
}
if (addr != null) {
System.out.println( addr.getCanonicalHostName() );
}
} catch (...) { ... }