Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to identify the computer?

 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Rob Spoor
Sheriff
Pie
Posts: 20526
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 507
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6109
6
Android IntelliJ IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 507
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 507
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12122
30
Chrome Java Linux
  • Likes 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64824
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Yohan Weerasinghe
Ranch Hand
Posts: 507
Java Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 20526
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.util.prefs.Preferences could be used. That uses the registry on Windows, but other operating systems will use different techniques.
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe licensing could help you achieve your goal in a slightly different way?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic