• Post Reply Bookmark Topic Watch Topic
  • New Topic

getHardwareAddress returning null  RSS feed

 
Arvind Subramanian
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sf84.cube.net
127.0.0.1
false
lo
true
Exception in thread "main" java.lang.NullPointerException
at Test.getMacAddress(Test.java:30)
at Test.main(Test.java:46)

The below code is working in all system Linux(fedora, centos) and windows except one system(linux). It is giving null pointer exception at marked line.. I checked the rights and permission. Still there is prob. Can anyone tell me the reason for it.




Thanks in advance
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the Javadoc:
Returns the hardware address (usually MAC) of the interface if it has one and if it can be accessed given the current privileges.

Returns:
a byte array containing the address or null if the address doesn't exist or is not accessible.

So eithere there is no MAC address, or you simply cannot access it (because you're not root).
 
Arvind Subramanian
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks rob, i aleady checked the docs before coding.
NIC is available and permission is also there.

I found the problem that its taking wrong network interface some virtual one. recoding for that.
 
Fred Hamilton
Ranch Hand
Posts: 686
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arvind Subramanian wrote:thanks rob, i aleady checked the docs b4 coding.
NIC is available and permission is also there.

I found the problem that its taking wrong network interface some virtual one. recoding for that.


recoding what exactly? might this not be a change in a linux configuration file that is required?

I get the impression that the concept of platform independance may have taken a hit here.
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arvind Subramanian wrote:b4

Use real words.
 
Arvind Subramanian
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fred, no change in lionux configuration, only in my program. To get the interface and check its macaddress present or not... but its very dependent to os, since for vista its getting lot of mac address. Working on it, i designed in simple way as by seeing docs, but its complexity is keep on increasing day by day... JAVAaaa....
 
Fred Hamilton
Ranch Hand
Posts: 686
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Arvind Subramanian wrote:Fred, no change in lionux configuration, only in my program. To get the interface and check its macaddress present or not... but its very dependent to os, since for vista its getting lot of mac address. Working on it, i designed in simple way as by seeing docs, but its complexity is keep on increasing day by day... JAVAaaa....


noted. I'm just learning about Linux now, so this caught my attention. regards.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!