penang67
asked on
Java read machine address
Dear all, i am planning to use the machine address to be the unique character to determine my licensing program.
I have code this code,
Enumeration enu = NetworkInterface.getNetwor kInterface s();
while (enu.hasMoreElements()){
System.out.println(enu.nex tElement() );
}
..
..
**********
name:lo (MS TCP Loopback interface) index: 1 addresses:
/127.0.0.1;
name:eth0 (Realtek RTL8168/8111 PCI-E Gigabit Ethernet NIC - Packet Scheduler Miniport) index: 2 addresses:
/11.11.10.29;
name:eth1 (Bluetooth PAN Network Adapter - Packet Scheduler Miniport) index: 65540 addresses:
/121.145.50.1;
*****************
and it's doesn't seems what i am looking for.
What i am looking is something which is unique and the best in mind is the Network Interface Card number.
Can you help??
I have code this code,
Enumeration enu = NetworkInterface.getNetwor
while (enu.hasMoreElements()){
System.out.println(enu.nex
}
..
..
**********
name:lo (MS TCP Loopback interface) index: 1 addresses:
/127.0.0.1;
name:eth0 (Realtek RTL8168/8111 PCI-E Gigabit Ethernet NIC - Packet Scheduler Miniport) index: 2 addresses:
/11.11.10.29;
name:eth1 (Bluetooth PAN Network Adapter - Packet Scheduler Miniport) index: 65540 addresses:
/121.145.50.1;
*****************
and it's doesn't seems what i am looking for.
What i am looking is something which is unique and the best in mind is the Network Interface Card number.
Can you help??
or else You can use..
getHardwareAddress() api of NetworkInterface class
getHardwareAddress() api of NetworkInterface class
ASKER
the InetAddress doesn't have the get MAC address method.
getHardwareAddress() returns the MAC Address
But it is available from jdk 1.6 version..
If you want to get the MAC Address in < 1.6 version..
Then you have execute os command using
Runtime.exec("oscommand") and grep from the MAC address from the output
But it is available from jdk 1.6 version..
If you want to get the MAC Address in < 1.6 version..
Then you have execute os command using
Runtime.exec("oscommand") and grep from the MAC address from the output
ASKER
can you show how to get it from getHardwareAddress() from the inetaddr???
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
cmalakar, thanks for your help. Can you help to explain, how is this statement mean??
String temp = Integer.toHexString(b[i] & 0xff);
the toHexString(int i) how come become b[i] & 0xff and why '0Xff'??
thanks
String temp = Integer.toHexString(b[i] & 0xff);
the toHexString(int i) how come become b[i] & 0xff and why '0Xff'??
thanks
Refer Comment ID:20812688
in https://www.experts-exchange.com/questions/23128320/Reading-a-File-into-a-a-Byte-Array.html
Hope this helps
in https://www.experts-exchange.com/questions/23128320/Reading-a-File-into-a-a-Byte-Array.html
Hope this helps
netaddr.getHostName(); // will return the hostname
netaddr.getHostAddress(); // will return the host ip address