Why not just hard code an expiry date into the trial program so that you don't have to continue to support it? You could put this in main().
// Die after October 1, 2010
Calendar expireDate = Calendar.getInstance();
// January is 0 (y, m, d)
expireDate.set(2010, 9, 1);
// Get current date and compare
if (Calendar.getInstance().after(expireDate)) {
// Die
System.exit(0);
}
This is how Microsoft distributes their large scale beta software. They just give it an expiry date.
If you're talking about preventing reverse engineering or modifying the code, you can't. You could obfuscate the compiled program, but this won't stop the people who would be reverse engineering your code anyway.