<p>I would like to retrieve the ethernet address of the network interface that is used to access a particular website.</p>

<p>How can this be done in Java?</p>

<p><strong>Solution</strong> Note that the accepted solution of <code>getHardwareAddress</code> is only available in Java 6. There does not seem to be a solution for Java 5 aside from executing i(f|p)confing.</p>

You can get the address that connects to your ServerSocket using
http://java.sun.com/javase/6/docs/api/java/net/NetworkInterface.html#getInetAddresses()
However if your client is connecting via a NAT, then you will get the address of the router and NOT the Ethernet address. If it is on your local network (via a hub/switch, no router with NAT) the it wil work as intended.