I am new to commercial software development. I am working towards developing 2 versions of a Java based tool.
1) Trial Version (30 Days free use)
2) Full version
As I understand for the trial version the start date has to be recorded in registry or conf file. But I am unable to identify how can I write a Java program which will write a timestamp to registry and conf files.
Can anyone please help me understand how to do so.
Preferences API is what you need.
But going back to your original goal, it is much more difficult to implement such system than just writing your timestamp into the system repository or some other storage.
You need to be sure that:
You are using 'source' of time you can trust to
Nobody can change timestamp you have saved somewhere - you need to sign it in some way
You need to periodically update timestamp and store it in different places to defend yourself against time rollbacks (so system could say that current time is in past)
In ideal case you need to check license on some licensing server
Even if you are sure about your timestamp source, there is also high chances that your licensing library will be decompiled with JD-GUI and checking code removed.
To make your check strong enough you need:
Use obfuscation for all your system modules (have a look on http://proguard.sourceforge.net)
Keep in mind that someone can just add new dependency in the classpath and affect on your license logic in runtime
Put check method invocation in different places of your system
Use ciphering for all license-related data
Bind license to the particular machine using hardware IDs (CPU's, network devices, etc.)
Encode issuing date into the license by itself
License file need to encrypted with authorised authority key (read about public/private ciphering ) and your system build should be also signed with appropriate key which means that you need to have well defined system build & signing flow