• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

How to lock java app for single PC

 
Greenhorn
Posts: 24
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but i guess we can change computer name also....
so this will not be considered as unique.
 
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use the MAC address.
 
Marshal
Posts: 26912
82
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67595
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic