2

This is with reference to this SO answer. It states that the code below can be used to uniquely identify a machine:

import java.util.Scanner;

public class GetBiosSerialNumber {

    public static void main(String[] args) throws Throwable {
        // wmic command for diskdrive id: wmic DISKDRIVE GET SerialNumber
        // wmic command for cpu id : wmic cpu get ProcessorId
        Process process = Runtime.getRuntime().exec(new String[] { "wmic", "bios", "get", "serialnumber" });
        process.getOutputStream().close();
        Scanner sc = new Scanner(process.getInputStream());
        String property = sc.next();
        String serial = sc.next();
        System.out.println(property + ": " + serial);
    }
}

But this is for windows only. How do I make it work for OSX? And if its not possible to find an equivalent way of working on MAC, whats the other way to get unique machine id?(for Hardware Locking an application). Unfortunately I do not have a MAC PC to test this(I'm making it for a client), so please let me know a way that would work across all OSX devices.

I do not want to use the MAC address as the question in response to which above answer was there suggests several limitations of MAC address.

This post is not a duplicate of this other post. My first line of this question references an answer to that question only.

Community
  • 1
  • 1
rahulserver
  • 10,411
  • 24
  • 90
  • 164
  • http://stackoverflow.com/questions/933460/unique-hardware-id-in-mac-os-x – martinez314 Feb 10 '15 at 21:41
  • 1
    Not sure whats the reason for the downvote, but show me a single answer in that link that does gets the machine Id using JAVA. All the questions mostly are command line utilities or codes written using special c++ libraries and its nowhere clear how to wrap it using java @whiskeyspider – rahulserver Feb 12 '15 at 03:25
  • The example you posted is a command-line utility, called via Runtime, available in Windows. In the link I posted, the accepted answer is also a command-line utility, available in OS X. Call it via Runtime just as you do above. There is no pure-Java solution that I know of. (The downvote was not mine.) – martinez314 Feb 12 '15 at 14:38
  • 1
    @durron597 **READ THE QUESTION PROPERLY** I have referenced the answer to that question in the first line itself which you say above is a "duplicate" of. – rahulserver Jun 15 '15 at 02:23

0 Answers0