Is it possible to get the IP address and MAC address of the default gateway in java?

I am trying to find a way to access the IP and MAC addresses for the default gateway from the Java applet that will be launched on the website, is this possible?

+3
source share
3 answers

You cannot do such things in Java, for example, getting an SSID on a Wi-Fi network . This low-level hardware information cannot be obtained in Java in a cross-platform manner, and Java allows you to work only at the transport level (TCP), as well as use sockets.

If you need such information, try calling the OS command line tool using Runtime.getRuntime().exec(...) and parsing the output. But you have to deal with different OSs, which means different teams and tools.

But in the world of Applet, you cannot invoke OS command-line tools and not open files; you are in an isolated software environment that prohibits applets from performing certain low-level tasks that could jeopardize the user's computer.

If you sign your applet, you have privileges to perform the same operations as regular desktop applications, but this is beyond the scope.

Try to focus your task in a different direction.

+1
source

You can get the MAC address of the interface in Java using the getHardwareAddress method in the java.net.NetworkInterface class ( http://download.oracle. Com / JavaSE / 6 / documents / API / Java / network / NetworkInterface.html # getHardwareAddress () ) I'm not sure if this will work inside the Applet, and I have never tested this method myself, but if something does, this method is what you need.

+1
source

IP address? sure thing. Just ask the applet to connect to the server. An applet can open an http connection to the server that hosts it.

MAC and GW, by default, are system things that you can get through external programs, but I'm not sure if they are supported in the applet sandbox (in fact, they are probably not supported).

0
source

All Articles