Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7745063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:55:10+00:00 2026-06-01T09:55:10+00:00

i am using NetworkInterface class to get the MAC address but i am getting

  • 0

i am using NetworkInterface class to get the MAC address but i am getting null in my code NetworkInterface ni = NetworkInterface.getByInetAddress(inetAddr); .I am getting null in ni object,pleas suggest me the way to get the mac address of a device on lan.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T09:55:12+00:00Added an answer on June 1, 2026 at 9:55 am

    Try this code,

    import java.io.*;
    import java.net.*;
    import java.util.*;
    import java.util.regex.*;
    
    public class GetMac
    {
    public static void main(String[] args)
    throws IOException
    {
    String address = new GetMac().getMacAddress();
    System.out.println(address);
    }
    
    public String getMacAddress() throws IOException
    {
    String macAddress = null;
    String command = "ipconfig /all";
    Process pid = Runtime.getRuntime().exec(command);
    BufferedReader in =
    new BufferedReader(
    new InputStreamReader(pid.getInputStream()));
    while (true) {
    String line = in.readLine();
    if (line == null)
    break;
    Pattern p = Pattern.compile(".*Physical Address.*: (.*)");
    Matcher m = p.matcher(line);
    if (m.matches()) {
    macAddress = m.group(1);
    break;
    }
    }
    in.close();
    return macAddress;
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using this code to find the MAC address of a machine. This
I'm trying to get the MAC address for the network adapter of the user's
I want to accesss the mac address of the computer using c#. I have
Using the code below I will get all network interfaces which are enabled and
I am using NetworkInterface.GetAllNetworkInterfaces() to get all the interfaces on a PC. However, this
I am using the following function to get the local IP address of the
I want to get the MAC address for my network interface on Linux. I
I'm using Android with Api level 8 and I want to get the Address
I'm using this code: NetworkInformation.NetworkInterface[] interfaces = NetworkInformation.NetworkInterface.GetAllNetworkInterfaces(); the above code retrieving only the
Every time I start my network interface, I get a different MAC address! If

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.