This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Building Blockchain Apps and have Michael Yuan on-line!
See this thread for details.
Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • 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
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

How to lock java app for single PC

 
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..
 
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.
 
Marshal
Posts: 67366
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the MAC address.
 
Marshal
Posts: 25223
65
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
Marshal
Posts: 67366
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • 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.
 
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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • 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
 
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.

 
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 https://coderanch.com/t/536081/java/java/help-Locking-Java-Code-MAC
 
Listen. That's my theme music. That's how I know I'm a super hero. That, and this tiny ad told me:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!