aspose file tools*
The moose likes Java in General and the fly likes How to identify the computer? 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 identify the computer?" Watch "How to identify the computer?" New topic
Author

How to identify the computer?

Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

I am creating a small Java program. In there, I am creating a file called "James.txt". I am using this file to check whether the program has been moved from James computer or not. What I have done there is, writing Jame's computer's IP address to that file. So, when he start the program in the console, it will first check the file and will say "Hey James! Suprise!!!", and if the IP isn't belong to james it will print "Sorry, This is for James Party".

But, the case is, IP address can be changed even in the same PC right? So, how can I uniquely identify James computer? Please help!

Are you better than me? Then please show me my mistakes..
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

You can try the MAC address. I believe that's available from NetworkInterface. However, that too can be changed, although must be done manually. Most users don't even know how to.

Other than that you'll need to go native - use JNI to get some identifier for the hard drive(s), motherboard, etc.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Yohan Weerasinghe wrote:I am creating a small Java program. In there, I am creating a file called "James.txt". I am using this file to check whether the program has been moved from James computer or not. What I have done there is, writing Jame's computer's IP address to that file. So, when he start the program in the console, it will first check the file and will say "Hey James! Suprise!!!", and if the IP isn't belong to james it will print "Sorry, This is for James Party".

But, the case is, IP address can be changed even in the same PC right? So, how can I uniquely identify James computer? Please help!


If user Joe Hacker is smart enough to change his IP to circumvent this, he's also smart enough to delete James.txt, so that your program will think it's being run for the first time, so it will create Joe_Hacker.txt and say "Hi Joe Hacker!"

So if you use the MAC address to foil these individuals, they'll still be able to get around it by simply deleting or changing the text file.
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

Rob Spoor wrote:You can try the MAC address. I believe that's available from NetworkInterface. However, that too can be changed, although must be done manually. Most users don't even know how to.

Other than that you'll need to go native - use JNI to get some identifier for the hard drive(s), motherboard, etc.


Thanks for the reply Rob. I really appreciate it Is that is true that there will be a problem if the user replace his network card?
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Yohan Weerasinghe wrote: Is that is true that there will be a problem if the user replace his network card?


Yes, since the MAC will change.
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

Jeff Verdegan wrote:
Yohan Weerasinghe wrote: Is that is true that there will be a problem if the user replace his network card?


Yes, since the MAC will change.


OH god. Then I an unable to use it.

Is there a way to insert a registry entry? But it should work in all the platform which Java supposed to work with
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

And, it must not based on Hardware. For an example, users OS might change, in this case, it is OK not to identify it. Users OS might crash, in here also it is OK. It must not based on hardware.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11328
    
  16

I guess the question is what do you consider "the same computer"? If a user changes the mother board, is that a new computer? what if they get a new hard drive? a new graphics card?

What's confusing (to me) is that you are saying "We can't use hardware to determine if it is the same computer or not" - but isn't that exactly what defines one computer from another - the hardware?


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61241
    
  66

Yohan Weerasinghe wrote:Is there a way to insert a registry entry? But it should work in all the platform which Java supposed to work with

FAIL. The registry is obviously Windows-only.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Yohan Weerasinghe
Ranch Hand

Joined: Oct 07, 2010
Posts: 499

Bear Bibeault wrote:
Yohan Weerasinghe wrote:Is there a way to insert a registry entry? But it should work in all the platform which Java supposed to work with

FAIL. The registry is obviously Windows-only.


Oh god

Thanks for everyone for the replies. I really appreciate it. I decided to give up this idea and implement something else.
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19697
    
  20

java.util.prefs.Preferences could be used. That uses the registry on Windows, but other operating systems will use different techniques.
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

Maybe licensing could help you achieve your goal in a slightly different way?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to identify the computer?