Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

how to get unique address

 
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
 
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
 
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.
 
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();
}
}
}
 
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!