This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to lock java app for single PC

 
shital sonavane
Greenhorn
Posts: 24
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to lock my java application for only one PC.
How can i achieve this? can anyone help me?
Thanks in advance..
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Most functioning PCs have a computer name. If you design your program to use this name to validate execution, your program will only work on one PC.
 
shital sonavane
Greenhorn
Posts: 24
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but i guess we can change computer name also....
so this will not be considered as unique.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65227
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the MAC address.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
However bear (no put intended) in mind that many computers these days have more than one network interface (Ethernet and wireless), each with their own MAC address. And also when a new network card is installed, it will have a new MAC address attached to it.

It's also (so I hear) possible for the user to change a MAC address.

So if you plan to use this MAC address to prevent people from accessing your software, be prepared to hear from people who have been unjustly prevented.
 
shital sonavane
Greenhorn
Posts: 24
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But as i have searched on google. we can not get mac id using java code directly.
We have to use JNI for this..
any idea how to get MAC id using JNI/java
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65227
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You apparently didn't search carefully.

java.net.NetworkInterface
 
shital sonavane
Greenhorn
Posts: 24
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear. it's working fine on linux machine. but not on windows machine.


this is the code which i tried to execute on windows and linux.
 
selva nayagam.K
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try the bellow code it will work fine
 
shital sonavane
Greenhorn
Posts: 24
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks selva.
But, This code is not working on linux machine.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15490
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
shital sonavane wrote:Thanks Bear. it's working fine on linux machine. but not on windows machine.

shital sonavane wrote:thanks selva. But, This code is not working on linux machine.

What does that mean "it is not working"? Do you get an error, or do you get output that's different from what you expected? If you get an error, then please tell us exactly what it is - that makes it a lot easier to help you solve the problem.
 
shital sonavane
Greenhorn
Posts: 24
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mac array is returning null on my linux machine.
so it is printing
Address doesn't exit ro it is not accesible
 
Ramesh Sunkara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Selva

I executed the code you posted here on my windows machine.

I got the following message.
Address doesn't exit ro it is not accesible


What could be the reason for that message in my system?
Can you please explain?


PS: The following code worked and gave my MAC address.

 
Todor Vachev
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
...
[MG removed hijack]
Please do not post your question in someone else's thread. Also do not post the same question multiple times. Let us continue the discussion of your problem in the other thread you started here http://www.coderanch.com/t/536081/java/java/help-Locking-Java-Code-MAC
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic