Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners how to get an lan system ip and mac address in java code
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


shruthibn
how to get an lan system ip and mac address in java code
2 Answer(s)      2 years and 9 months ago
Posted in : Java Beginners


strong text


Advertisement
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();
        }
    }
}


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
java get all ip addresses in a lan
java get all ip addresses in a lan  Anybody have any idea on using java or cpp on how to get the ip addresses of all the machines[win or linux... to know that a given ip address computer is connected in a LAN?. I could supply
Advertisements
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
PHP Get Browser IP Address
PHP Get Browser IP Address PHP provides us  $_SERVER['REMOTE_ADDR'] function is used to display the Browser IP address PHP Get IP Address Code: <?php echo "My Browser IP is :". $_SERVER['REMOTE_ADDR']; ?>
MAC ADDRESS - Java Beginners
MAC ADDRESS  codings to fetch MAC address of a system in Java
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
getHostAddress() returns the IP address.     Here is the code of Java Get IP... Java Get IP Address       This section illustrates you how to obtain the IP Address of local host
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
Get System Ip
Get System Ip       The System IP address is a unique numerical identification... to get a IP address. For this we have a class name GetSystemIP,Inside the main
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
finding the ip address of other system and store in the database - JDBC
finding the ip address of other system and store in the database  code to find the ip address,host name and their locale of other system... in database.if any other system tries to connect our system ,we have to find the ip address
PHP GD Get System IP
<?php $image = imagecreatetruecolor(150,70); $ip = "$_SERVER[REMOTE_ADDR]"; imagestring($image, 10, 20, 36, $ip, 0x00ff00); header... running the program you will get the following output
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
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
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
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
block IP of LAN machines from server - RMI
block IP of LAN machines from server  i want to block the IP... server. IP block means,I want to restrict them to access the internet. so, how is it possible to block IP of LAN machines from server
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
Java Get Host Name
; In this Example you will learn how to get host name in Java. Go through... of a computer or an IP address using Java application language. The given program...; Java code to get host name import java.net.
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 example
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
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
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
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   
Get GMT from IP
Get GMT from IP  How do I get GMT value from IP address?? Thanx in Adv
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
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 
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
Overview of Networking through JAVA,Find the Host name in reverse of given IP address
Find the Host name in reverse of given IP address... and create a class object and pass the IP address in InetAddress.getByName() method. Now retrieve the Host name of the IP address what we are pass in getByName
code for LAN Messenger - JSP-Servlet
code for LAN Messenger  User has to add the Valid System Name (the Name of the System on the LAN). After Adding System Name, he just have to Select the System Name (He can Add Multiple System Name at a Time. But Message can
 

 

 

DMCA.com