Reputation: 63
I'm trying to find a way to access the IP and MAC addresses for the default gateway from a java applet to be run on a website, is this possible?
Upvotes: 3
Views: 6352
Reputation: 10493
You can get the Mac Address of an interface in Java using the method getHardwareAddress
in the class java.net.NetworkInterface
(http://download.oracle.com/javase/6/docs/api/java/net/NetworkInterface.html#getHardwareAddress()). I am not sure if that will work inside an Applet, and I have never tested that method myself, but if something does it, this method is that thing.
Upvotes: 1
Reputation: 2725
You can't do that kind of thing in Java, like getting the SSID on a Wifi network. This low-level hardware information can not be obtained in Java in a cross-platform way and Java only allow you to work in the Transport (TCP) level, aka use sockets.
If you need this kind of information, try invoking a OS command tool using Runtime.getRuntime().exec(...)
and parsing the output. But you have to deal with different OS that means different commands tools and outputs.
But in the Applet world, you can't invoke OS command tools, nor opening files, you are in a sandbox that prevents Applets for doing some low-levels tasks that can put in risk the user computer.
If you sign your applet, you have privileges to perform same operations like regular desktop applications, but this is out of scope.
Try to focus you problem in another direction.
Upvotes: 1
Reputation: 12351
The IP Address? sure thing. Just have the applet connect back to your server. An applet can open an http connection to the server that hosts it.
The MAC and Default GW are system specific things you could get via external programs, but I'm not 100% sure those are supported in the applet sandbox (in fact, they're probably not supported).
Upvotes: 0