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 7042393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:09:46+00:00 2026-05-28T02:09:46+00:00

I am writing a java webstart application to deploy from website so users can

  • 0

I am writing a java webstart application to deploy from website so users can click and run my software. I need to have a kind of unique machine identification to avoid abusing the accessing of the files. I would like to use the client’s MAC address as a unique key so that the server can ensure that no client downloads too much.

Of course, a user may have multiple network cards, so how can my Java application determine the MAC address of the network card that the user is using to access my web site?

  • 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-05-28T02:09:47+00:00Added an answer on May 28, 2026 at 2:09 am

    You can use java.net.NetworkInterface.getNetworkInterfaces to obtain the network interfaces, and call getHardwareAddress() on them to get the MAC address.

    You may want to filter out loopback with if.isLoopBack() (where “if” is the interface object). Also filter out any interface where if.getHardwareAddress() returns null. Then pick out one. You could sort them by name, if.getName(), and take the first one. For your purposes it doesn’t really matter if it is the actual interface used to download your files or not, just that you can identify the computer somehow. Finally if.getHardwareAddress() gives you an array of bytes with the MAC address. If you’d rather have a String, format each byte with “%02x”.format(byte) and join them with a “:” as separator.

    As suggested in another answer it may be better to use PersistenceService.

    Using the MAC address can however be useful if you want to persist different data for the same user on different computers in the case where the user has the same files/homedirs on each computer. You can use the MAC address as part of the URL you pass to PersistenceService#create() and get(). Useful if you want per-computer data rather than per-user data.

    Short example Scala-code:

    def computerID: String = {
      try { // mac address of first network interface
        return java.net.NetworkInterface.getNetworkInterfaces
        .filter(!_.isLoopback)
        .filter(_.getHardwareAddress != null)
        .toList.sortBy(_.getName).head
        .getHardwareAddress.map("%02x".format(_)).mkString(":")
      } catch {
        case _ => return "0" // no mac address available? use default "0"
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing java code where i need to get some information from a
Writing a Java application using the Play framework and need some HTTP-Live streaming. I
I need help in writing java code that can connect to a remote UNIX
I'm in Eclipse writing Java. I come from Visual Studio with Resharper writing C#.
I'm writing a Java application that runs on Linux (using Sun's JDK). It keeps
I'm writing a Java Tree in which tree nodes could have children that take
I am writing Java application, which is totally GUI-less. It runs in terminal through
I'm a C# programmer writing Java (for Android) and have a few technicalities of
I'm writing java application that is using both SQLite and MySQL using JDBC. Are
I have been writing java for a while, and today I encountered the following

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.