aspose file tools*
The moose likes Java in General and the fly likes how to get unique address Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to get unique address" Watch "how to get unique address" New topic
Author

how to get unique address

Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
hi all
I am developing a application using java. In which I have to get the unique unchangable address from client like any hardware device of his PC.
so plz help me out how can I get the h/w add using java



thanks
James Carman
Ranch Hand

Joined: Feb 20, 2001
Posts: 580
Are you wanting something like a MAC address? You can't do that using pure Java. You would have to use JNI to get something like that.


James Carman, President<br />Carman Consulting, Inc.
Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
ya James
something like MAC OR HARD-DISK /MOTHER BORAD

if it is done by JNI can you suggest me how to start by JNI

thanks
M Beck
Ranch Hand

Joined: Jan 14, 2005
Posts: 323
well, first you'd have to find a unique, unchangeable address somewhere in the hardware. on most PCs, that is not entirely straightforward; MAC addresses, firmware versions, pretty much anything i can think of in a regular PC can either be changed in software or might not even be there. unless you have a specific manufacturer and model of hardware in mind, your task may be hard with or without Java.
Aj Mathia
Ranch Hand

Joined: Apr 11, 2003
Posts: 478
U can get the mac address with this
import java.io.*;

public class MacProcess {
public MacProcess() {
}
public static void main(String[] args) {
MacProcess macProcess1 = new MacProcess();
macProcess1.pro();
}
public void pro(){
String s = null;
StringBuffer sb = new StringBuffer() ;
try {
Process p = Runtime.getRuntime().exec("ipconfig /all");
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
while ((s = stdInput.readLine()) != null) {
sb.append(s);
}
int i = sb.indexOf("Physical Address. . . . . . . . . :");
i+=36;
String ss = sb.substring(i,i+17);
System.out.println("Mac Address : " + ss);
}
catch (IOException e) {
e.printStackTrace();
}
}
}


You think you know me .... You will never know me ... You know only what I let you know ... You are just a puppet ... --CMG
Jeffrey Spaulding
Ranch Hand

Joined: Jan 15, 2004
Posts: 149
Originally posted by Ajay Mathew:

try {
Process p = Runtime.getRuntime().exec("ipconfig /all");
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
while ((s = stdInput.readLine()) != null) {

...

}


If you happen to use windooze



J.
Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
hi
thanks All
I did this using ipconfig/all
& got the MAC Address
but I have to identify a system ..in which user hasn't Interface card...
so I'll have to capture Hard disk address or any other fix H/W address.

thankx
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get unique address