I have a java program compiled as a .jar
and it requires an activation key to be enabled. I want the jar
to prompt you for the activation key on the first runtime
and once its been activated, store a string which it could read during later runtimes
to determine if it had been enabled.
Any suggestions on how to go about this?
Note: I want the string to be stored secretly so someone couldn't trick the program into thinking its been enabled.
Update: I've been toying with the preferences api and am using this code to store if the program has been enabled:
String key = "userKey";
String saveString = "enabled";
Preferences root = Preferences.userRoot();
root.put(key, saveString);
And this to get if during a later runtime:
String key = "userKey";
String failedtoLoad="Program not enabled";
Preferences root = Preferences.userRoot();
String status=root.get(key, failedToLoad);
Everytime I run the program status ends up being failedtoLoad and the saveString isn't found, unless I save the string and get the string in the same runtime. Why is this?