how to get an lan system ip and mac address in java code

Ads
 

how to get an lan system ip and mac address in java code

strong text

View Answers

January 12, 2012 at 5:15 PM

Java get system IP Address:

import java.net.*;
import java.io.*;

public class GetIPAddress {
public static void main(String [] args) {
try {
InetAddress thisIp =InetAddress.getLocalHost();
System.out.println("IP:"+thisIp.getHostAddress());
}
catch(Exception e) {
e.printStackTrace();
}
}
}

January 12, 2012 at 5:24 PM

Java get Mac Address:

import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.net.UnknownHostException;

public class MacAdd {

    public static void main(String[] args) {
        try {

            InetAddress add = InetAddress.getByName("192.168.20.53");


            NetworkInterface ni1 = NetworkInterface.getByInetAddress(add);
            if (ni != null) {
                byte[] mac1 = ni1.getHardwareAddress();
                if (mac1 != null) {

                    for (int k = 0; k < mac.length; k++) {
                        System.out.format("%02X%s", mac[k], (i < mac.length - 1) ? "-" : "");
                    }
                } else {
                    System.out.println("Address doesn't exist ");
                }
            } else {
                System.out.println("address is not found.");
            }
        } catch (UnknownHostException e) {
            e.printStackTrace();
        } catch (SocketException e) {
            e.printStackTrace();
        }
    }
}

Ads









Related Tutorials/Questions & Answers:
how to get an lan system ip and mac address in java code
how to get an lan system ip and mac address in java code  strong text
Get IP Address in Java
Get IP Address in Java In this example we will describe How to get ip address in java. An IP address is a numeric unique recognition number which...(). getHostAddress(). InetAddress():-The InetAddress is class represents an IP address
Advertisements
Java example program to get IP address of own system
Java example program to get IP address of own system       java get own IP address An IP... the computer system's local host with IP address. Now we can get the IP address
Java Get IP Address
of "How to get IP Address in Java?": Here is the code of Java Get... Java Get IP Address       This section illustrates you how to obtain the IP Address
Getting IP address of All the machines
Getting IP address of All the machines  Program how to fetch All the IP address on my domain(LAN) in java
How to find MAC(Hardware address) address of access point
How to find MAC(Hardware address) address of access point  How can i find out MAC address of Access Point using java
How to get client's address in a servlet
How to get client's address in a servlet       This is detailed java code to get...() of the ServletRequest interface which returns IP address of the client
Find Exact Location from IP address in java?
Find Exact Location from IP address in java?  I am looking for API where we can pass IP address and get the location (Cityname,Country name). please suggest any API OR sample code. Thank you
Java Get Host Name
;  In this Example you will learn how to get host name in Java... name of a computer or an IP address using Java application language. The given... by default. Here is the video tutorial of "How to get Host Name in Java
Java Get Example
in the network for communication. To get IP address of our own system in a java... Get examples like how to get the date and time, IP Address or memory size etc... practice   IP Address:  This Java Get IP Address
Getting IP Address
Getting IP Address  Hi... i want to get the ip address of the current... get the ip address 247 in database but i need to get the ip address of that particular system.... how to get that please help me doing that... thank
Getting IP Address
Getting IP Address  Hi... i want to get the ip address of the current... get the ip address 247 in database but i need to get the ip address of that particular system.... how to get that please help me doing that... thank
Java get System Locale
Java get System Locale       In this section, you will learn how to obtain the locale. We... of the system. Here is the code of GetSystemLocale.java class 
Get IP Address Example
Get IP Address Example       This example shows you ip address of your... : NetworkInterface.getNetworkInterfaces() : Network Interface class is used for get name, and a list of IP
How can I find my DHCP IP address on my computer?
How can I find my DHCP IP address on my computer?  Hi, I am using.... How to find the IP address? Thanks   Hi, You can try following command? Here is the command to get the IP address: cat $(ps aux | grep -o '[/]var
uploading a file at another system in lan using jsp
uploading a file at another system in lan using jsp  Thanks...". It is working when i gave address of the local system to savefile But if i want to save or upload the file at another system in lan at location "http
Get GMT from IP
Get GMT from IP  How do I get GMT value from IP address?? Thanx in Adv
How to get system current cursor type
How to get system current cursor type  In Windows how can i get the current mouse/keyboard cursor type like 'text cursor' from my java application
Java example program to get Operating System type or architecture
by using the system property. Here this java example code displays how one can get... Java example program to get Operating System type or architecture... environment we can write java code which will make us enabled to get
Find Your Host Name/IP Address
, In which the host name of the local system is Comp20 and the IP address... Ipaddress.java C:\roseindia>java Ipaddress Local IP Address... Find Your Host Name/IP Address   
IP Address validation
IP Address validation  hi,I m now working with my final yr project,nd stuck in th middle i don't know how to validate the IP address in a JText field...(ie) the user shld enter the IP address in JTxt and when he hit the 'Submit
FTPClient : Get System Type
This section explain how to get system type by using method of FTPClient class in java
Visitor IP Address and Host Name using jsp
Visitor IP Address and Host Name using jsp  I have created one jsp page and i want to display the ip address of the visitor in my page. I used the following code to get the ip address: String ip=request.getRemoteAddr(); But i am
ModuleNotFoundError: No module named 'ip-address'
'ip-address' How to remove the ModuleNotFoundError: No module named 'ip...ModuleNotFoundError: No module named 'ip-address'  Hi, My Python... have to install padas library. You can install ip-address python
ModuleNotFoundError: No module named 'ip-address'
'ip-address' How to remove the ModuleNotFoundError: No module named 'ip...ModuleNotFoundError: No module named 'ip-address'  Hi, My Python... have to install padas library. You can install ip-address python
Collect Mac Address Connected via Bluetooth
Collect Mac Address Connected via Bluetooth  How to collect automatically all mac address connected via bluetooth and save in a file
How to get Java SDK
How to get Java SDK  Hi, I have purchased a new computer and installed windows 7. Now I have to get the Java SDK and install on my computer for developing and testing Java programs. So, can anyone tell me How to get Java SDK
How to get current timestamps in Java
How to get current timestamps in Java  Hi, I want to get the current Timestamp in Java and then use it in JDBC program. How to get current timestamps in Java? Thanks   Hi, In Java using get the current Timestamp
How To Unblock IP address from command line in CSF Firewall ââ?¬â?? Linux Server?
How To Unblock IP address from command line in CSF Firewall ΓΆβ?¬β?? Linux Server?  Hi, How To Unblock IP address from command line in CSF Firewall... the ip and then restart the csf server using following command: csf -r
please let me get code how to insert a data to mysql using setter and getter method by using java
please let me get code how to insert a data to mysql using setter and getter method by using java  please let me get code how to insert a data to mysql using setter and getter method by using java pelease let me have the code
please let me get code how to insert a data to mysql using setter and getter method by using java
please let me get code how to insert a data to mysql using setter and getter method by using java  please let me get code how to insert a data to mysql using setter and getter method by using java pelease let me have the code

Ads