I don't think you can prevent anyone from making a copy of the software. it's just not possible.
What you can do is try and make it unusable if they don't pay for it. You can try and lock it down with licensing, you can have it ping a server you control, or you can try various other things. But ultimately, no matter what you do, people will be able to figure out a way to crack it if they want.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
With truth, protecting of software is a some kind of keeping secret.
Java is pretty weak in this case.
By default Java bytecode may be decompiled to very good readable Java code,
so any one can do so, switch your logic and compile code back again.
You may use bytecode obfuscation technique to prevent it, but for user
who really want to crack your software it will be only a minor barrier.
Two ways how to implement software protection:
1. Use a network repository to check user software licence, steps:
- Ship a licence key to user
- Licence key is entered into your application form
- Application requests a License Server to generate installation key, additional data is something related to hardware (MAC/IP/etc.)
- Licence server generates Installation key which is locked (some way) to this hardware settings (i.e. Intallation key will not work on other machine)
- check Installation key some times as your want.
2. Use a "secret" file
- Ship a Licence file to user
- User may put it into installation directory of your application (for example)
- on first run - copy this file somewhere outside installation directory (prevent this operation if installation file is 7 days old after shipment, for example)
- check the copy each time
Also, you may find RSA useful.
It is just a couple of solutions, but I'm not an expert in this area.