Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getHardwareAddress returning null with JDK 6 Update 22 enabled browser

 
Nitin Sinha
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm using the follwoing code and calling it in an applet. It used to work completely fine when I used with browser with JRE 6 Update 21. However, the code is now returning null for all browsers that support JRE 6 Update 22. Here is the code -

 
Nitin Sinha
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is a specific business requirement for which I need hardwareaddress.
thats why i posted the code.
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does it print if you try that code on a command line? I tried it (after removing the remaining call to checkValidMAC), and the only null MAC address was that of my "lo" adapter - which is the loopback adapter, and not really a physical device.
 
Nitin Sinha
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
TRY THIS CODE THEN -

 
Paul Clapham
Sheriff
Pie
Posts: 20764
30
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That code doesn't compile for me because there's no checkValidMAC method declared anywhere.

By the way you appear to be in the habit of cross-posting your questions on the Oracle forum. Please read this: BeForthrightWhenCrossPostingToOtherSites.

 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Again, if I run that code after changing line 43, I see all my network adapters - lo, two VMware virtual adapters and my actual network adapter (well, the one that isn't disabled - I have two). The MAC address (LAN ID) printed at the bottom is my actual MAC address. So I'll ask you again - what is the output when you run it?
 
Campbell Ritchie
Sheriff
Posts: 48424
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Never, never write == false or == true.
Those lines with multiple || checks are too long to read; they ought to have newlines in to break them up.
The multiple || look very inelegant. See if you can create a regular expression to match the multiple possibilities.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic