This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

getHardwareAddress returning null with JDK 6 Update 22 enabled browser  RSS feed

 
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.
 
Sheriff
Posts: 21462
96
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 -

 
Sheriff
Posts: 23714
50
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
Posts: 21462
96
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?
 
Marshal
Posts: 60194
188
  • 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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!