Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to get unique address

 
Vijay Kumar
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 580
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vijay Kumar
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 323
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 478
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
}
}
}
 
Jeffrey Spaulding
Ranch Hand
Posts: 149
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic