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

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 6 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
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
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
How to detect system failure using java code - Java Beginners
How to detect system failure using java code  I am doing a project... to detect the process that make failure. I have no idea about the project so please help me. And i need some site to download java source code
how to turn off bluetooth on mac
how to turn off bluetooth on mac  I want to know ..how to turn off the bluetooth on my mac system. Thanks
how to turn off bluetooth on mac
how to turn off bluetooth on mac  I want to know ..how to turn off the bluetooth on my mac system. Thanks
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
how to get current date without system date
how to get current date without system date  is there any possiblity to get current date instead of system date in Java, as i dont want to change date in program and if i change date in OS automatically change in program also
Problem in setting IP address for a JFrame Class Desktop Application
. But when we put it in a system which has a proxy setting for internet connection, the browser is unable to load anything. I don't know how to set IP address for our...Problem in setting IP address for a JFrame Class Desktop Application  
Get IP Example
Get IP Example       This example shows you ip address of your network...() : Network Interface class is used for get name, and a list of IP addresses
Overview of Networking through JAVA,To retrieve the IP address from Host Name, vice-versa
To retrieve the IP address from Host Name, vice-versa... to explain the method to find out the IP address from host name and to vice verse. Here... with getHostAddress() which return the IP address of that Host . If the user enter any
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
FTPClient : Get System Type
This section explain how to get system type by using method of FTPClient class in java
JSP:How to get year of system date - Date Calendar
JSP:How to get year of system date  Please tell me how to get year of system date; I am doing import java.util.*; Date d = new Date(); d.getYear...://www.roseindia.net/java/java-get-example/ Thanks
problem in sending data from one ip to another ip in JAVA
(like ping),after that i want send the data with my system(Ip) to another ip device in JAVA. i know how to ping but don't how to send the msg's to another IP...problem in sending data from one ip to another ip in JAVA  Hi guys
Java Networking - JSP-Servlet
Java Networking  I want to get all systems' (computer,printer,laptop) IP address on LAN using java code. I tried a lot but find only my system's IP. I want java code for dat
To retrieve the IP address from Host Name, vice-versac
To retrieve the IP address from Host Name, vice-versa... to explain the method to find out the IP address from host name and to vice verse. Here... with getHostAddress() which return the IP address of that Host . If the user enter any
Java get System Properties
Java get System Properties       In this section, you will learn how to obtain the system properties. The System class provides a Properties object that describes
How TCP/IP works ?
How TCP/IP works ?  hello,, Can some body tell me how TCP/IP works?   hii, TCP/IP is just a protocol that allows different nodes on the network/Internet to share resources and without TRANSMISSION CONTROL PROTOCOL
Java get System Locale
Java get System Locale       In this section, you will learn how to obtain the locale. We are providing you an example which will obtain the locale of the system by using
Java example program to get the operating system's version
Java example program to get the operating system's version... check your current system's operating system version by the java code also... how one can use the System.getProperty() method to get Operating System Version
VoIP LAN
;   VoIP LAN Phone IN-Call LAN Phone is a full-featured IP... communication. Over the office LAN, it provides IP-PBX solution such as station... of voip LAN phone : * IP Handset with display panel and RJ45 interface
 

 

 

DMCA.com