|
how to get mac and ip address using java
|
|
06-14-2009, 10:17 PM
Post: #1
|
|||
|
|||
|
how to get mac and ip address using java
hello,
please help me, i need to get the mac and ip address of my pc using java program for a project. thanks in advance. |
|||
|
06-15-2009, 01:59 AM
Post: #2
|
|||
|
|||
RE: how to get mac and ip address using java
(06-14-2009 10:17 PM)rahuljin Wrote: hello, To get the IP address try the following code. Code: java.net.InetAddress address = java.net.InetAddress.getLocalHost();To get the Mac address try this. Code: java.net.NetworkInterface networkInterface = java.net.NetworkInterface.getByInetAddress(address); |
|||
|
06-15-2009, 02:06 AM
(This post was last modified: 06-15-2009 02:07 AM by rahuljin.)
Post: #3
|
|||
|
|||
|
RE: how to get mac and ip address using java
thanks for the help.
|
|||
|
10-08-2009, 01:28 PM
(This post was last modified: 10-08-2009 01:44 PM by albinjoseph.)
Post: #4
|
|||
|
|||
|
RE: how to get mac and ip address using java
MAC addresses are used on a local networking, for example, between two hosts to communicate basic data. This does not include Internet traffic. However, once I want to visit Experts-Exchange, my addressing must be converted to IP. In other words, the MAC address of Experts-Exchange is foreign to me. Please keep this in mind for whatever your application may be.
|
|||
|
03-12-2010, 09:11 PM
Post: #5
|
|||
|
|||
|
RE: how to get mac and ip address using java
It is very easy process to get MAC address using java code. Just try to run following code in your PC.
import java.net.InetAddress; import java.net.NetworkInterface; public class Main { public static void main(String[] args) throws Exception { InetAddress addr = InetAddress.getLocalHost(); NetworkInterface ni = NetworkInterface.getByInetAddress(addr); byte[] maca = ni.getHardwareAddress(); for (int k = 0; k < maca.length; k++) { System.out.format("%02X%s", maca[k], (k < maca.length - 1) ? "-" : ""); } } } |
|||
|
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)





