This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Java in General and the fly likes getHardwareAddress returning null with JDK 6 Update 22 enabled browser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "getHardwareAddress returning null with JDK 6 Update 22 enabled browser " Watch "getHardwareAddress returning null with JDK 6 Update 22 enabled browser " New topic
Author

getHardwareAddress returning null with JDK 6 Update 22 enabled browser

Nitin Sinha
Greenhorn

Joined: May 08, 2008
Posts: 17
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

Joined: May 08, 2008
Posts: 17
this is a specific business requirement for which I need hardwareaddress.
thats why i posted the code.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Nitin Sinha
Greenhorn

Joined: May 08, 2008
Posts: 17
TRY THIS CODE THEN -

Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

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

Joined: Oct 27, 2005
Posts: 19649
    
  18

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

Joined: Oct 13, 2005
Posts: 37884
    
  22
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.
 
Consider Paul's rocket mass heater.
 
subject: getHardwareAddress returning null with JDK 6 Update 22 enabled browser
 
Similar Threads
How to allow only some computers to access the web application in internet?
getHardwareAddress returning null
Mac Address
How to lock java app for single PC
How to make a simple program to detect all connection between two computer??Thanx.