-2

I'm building an email sending software and user's requirement is, this program would be able to get and change the MAC address of the system. I searched over internet and found how can we get MAC address using java. Here I found a sample code that list all MAC addresses of the system. Using this code I have my output like this.

Current IP address : 169.254.74.152
Current MAC address : 00-27-10-52-D6-49
Current MAC address : 70-F3-95-82-2A-85
Current MAC address : 0A-00-27-00-00-11
Current MAC address : 0A-00-27-00-00-12
Current MAC address : 00-27-10-52-D6-48
BUILD SUCCESSFUL (total time: 2 seconds)

This output include MAC addresses of
1. Wireless LAN adapter WiFi
2. Wireless LAN adapter Local Area connection
3. Ethernet adapter Bluetooth
4. Ethernet adapter Virtual-box

It shows the same output irrespective of whether I'm connected to internet or not. So my question is how can I determine the one I'm connected with i.e. If I'm connected and using WiFi internet I need WiFi MAC and if I'm connected using Network Cable I need that.
And also tell how to change/spoof that MAC address using Java.

Community
  • 1
  • 1
Inzimam Tariq IT
  • 6,548
  • 8
  • 42
  • 69
  • 3
    Sounds like a bizarre requirement for an email sending software. – Kayaman May 17 '17 at 07:37
  • Java cannot change the MAC address. Send the requirement back for review. It's a control panel operation. Not something that needs to be built into any application. – user207421 May 17 '17 at 09:59

1 Answers1

0

It shows the same output irrespective of whether I'm connected to internet or not.

Of course it does. Your local MAC addresses don't change just because you're connected to the Internet.

So my question is how can I determine the one I'm connected with i.e. If I'm connected and using WiFi internet I need WiFi MAC and if I'm connected using Network Cable I need that.

You need it for what? There is nothing useful you can do with a MAC address in Java except to display it.

And also tell how to change/spoof that MAC address using Java.

You can't.

user207421
  • 305,947
  • 44
  • 307
  • 483