Also, please use real words when posting to the forums. Abbreviations such as "knw" in place of "know" only serve to make your posts more difficult to read and less likely to generate useful responses.
Please read this for more information.
Himanshu Kansal wrote:Alright, just in the interest of the community or atleast mine, do we have an answer to that?
Moreover is it ethical to do so if possible?
I am not really sure what you are trying to say here. Your first statement gives me the impression that "ok. enough of this rules and regulations. just give out the answer.". I am sure you did not mean it that way, but that's how it came off to me.
I also, am not sure what do you mean by ethical. Could you please rephrase?
There could be various reasons why nobody has posted the answer. For me, I know how to do it, but only on windows and the OP wants a cross platform solution.
That's all what I meant. No offences.
"Ethical" has been used as in "ethical hacking". Is getting SID ok?
Maybe he wants to secure his application in a way, so that it only runs on the computer for which his client bought a license. The program would check, by looking at some unique serial number of the harddisk or motherboard, if it's really running on the computer that the license was bought for.
Note that security measures like that are not infallible; someone who really wants to break the security could decompile or reverse engineer the application and try to remove the security check.
Anyway, this kind of thing is not possible in pure Java. You'd need a platform-specific native library for different platforms on which you want to support such a feature.
Jesper Young wrote: Why assume that manucng wants this because he is "hacking"?
Atleast I am not assuming this, other I don't know of. I use the term to explain the meaning of the word "ethical", would have been better to 'copy paste' from a dictionary I guess.
If such a mechanism is used for securing, re-installation is the easiest way to break it. Usually a registry key would be setup to prevent re-installation. Also such a mechanism would not be format safe.
Anyhow, I think we are deviating from the original question. If I may know, how can we do this?
Rob Prime wrote:You will have to go native, but you can simply provide two implementing libraries; one DLL ("javaranch.dll") for Windows and one shared library ("libjavaranch.so") for Linux.
means? whether i have to create mfc/win32 dll using visual studio?.if so i can create dll for windows os.i don know how to create for linux?.will the same dll work for linux?.
No, the same DLL will not work on Linux. You will need to write a shared library for Linux (which will be named "libsomething.so"). You'll have to learn how to program in C for Linux to do that.
If you also want to do it for Apple computers running Mac OS X, it's different again.
You'll need to use JNI to call those native libraries from Java.
For Linux, gcc is usually the way to go. No idea what Mac OS X uses.
manucng davangere wrote:i want to secure my application such that no one can steel my application using their thumdrive or EXTERNAL hard disk.i don want to read serial number of cd/internal hard disk.i can get code for windows os.but i want code such that it has to work for both linux and windows.
I'm confused by your stated aims versus your way of attempting to go about it. The only way I can reconcile this is if you were distributing your application on a thumbdrive, and wanted to confirm that the thumbdrive is present on it.
Personally, I would prefer to look for the network adapter's MAC address (using java.net.NetworkInterface#getHardwareAddress()). That should be unique per computer, and is unlikely to change very often.
I agree with Andrew here. If you need a value that is unique to a machine, the mac address is the way to go. These values are actually assigned by the vendors to make sure that they are unique -- as duplicate values will cause it to not work on a switch/hub.
And yes, they can be reassigned... and in the case of a virtual environment, I did this all the time, after copying a VM. You can also automatically get a new mac, when multiple NICs are bonded. etc. The point is... this is still probably your best bet at locking the application to a machine. Sure, a mac address can be reassigned, but if the user has that skill, he can decompile your program too, and even if the mac is reassigned, it won't work if it is on the same LAN as the other machine.