Right now I am using this code to retrieve the MAC Address of a system.
command = "cmd.exe /c ipconfig /all";
Process p = Runtime.getRuntime().exec(command);
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
This works fine when the user has defined a 'Path' in the environment variable with the value 'Systemroot/system32' but not without this.
So what I am trying to do is use this
command = "cmd.exe %systemroot%/system32/ipconfig /all";
Process p = Runtime.getRuntime().exec(command);
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
But this is not retrieving the MAC Address at all.
Can anyone please let me know what is wrong here or how to retrieve MAC address, the code for which is compatible in java 5 & above?
Is there any alternate solution?
The getHardwareAddress() doesn't work in java 5. I saw this in many posts, which doesn't suit to my app. My app is compatible to all tomcat and all java versions.
Please help...
I referred to and followed this How do I set environment variables from Java? also but without the environment variable the MAC address doesn't get read from the system. Any other suggestions please?