Depends. If you can leverage online website, you could port important and/or critical classes and pieces of code from your java program online. You can do more than just a serial check then :-)
Usually, what you would like, is to get 100% sure that the license is not leased, thus, if it was bought, then you should have IP of the guy that uses it, some of the hardware info (sounds familiar?) and such, I am not sure if this is a strong protection.
I encountered something similar to this in
here which nobody found a solution for.
If you cannot validate with the server, you won't be able to get anything to run, that is also, you won't get a class to run on and pieces of the program, much like a demo, but worse.
You could combine this with what the others proposed, and I think you will make someone very very busy for a lot of time :-)
Usually, reproducing a server to answer to requests of program takes too much time :-(