File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How to lock java app for single PC 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 lock java app for single PC" Watch "How to lock java app for single PC" New topic
Author

How to lock java app for single PC

shital sonavane
Greenhorn

Joined: Jan 28, 2011
Posts: 20

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

Joined: Apr 16, 2008
Posts: 2187
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

Joined: Jan 28, 2011
Posts: 20

but i guess we can change computer name also....
so this will not be considered as unique.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60063
    
  65

Use the MAC address.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18141
    
    8

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

Joined: Jan 28, 2011
Posts: 20

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

Joined: Jan 10, 2002
Posts: 60063
    
  65

You apparently didn't search carefully.

java.net.NetworkInterface
shital sonavane
Greenhorn

Joined: Jan 28, 2011
Posts: 20

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

Joined: Nov 16, 2009
Posts: 25
Try the bellow code it will work fine
shital sonavane
Greenhorn

Joined: Jan 28, 2011
Posts: 20

thanks selva.
But, This code is not working on linux machine.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13881
    
  10

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
shital sonavane
Greenhorn

Joined: Jan 28, 2011
Posts: 20

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

Joined: Mar 01, 2010
Posts: 78
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

Joined: Apr 27, 2011
Posts: 2
...
[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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to lock java app for single PC
 
Similar Threads
Corejava Question ??
Print Text via Bluetooth
Lock Desktop Using Java
Disable windows key
Need to lock my java application to single system