To get the basics out of the way, I'm using Eclipse to code and create my executable jar files.
Some background research:
I'm aware that you can decompile jar files and see the source code. In fact, there are free programs out there like JD GUI that can easily decompile a jar file and reveal all its contents. This is an issue especially if you want to distribute a java program.
When I learned about this, I immediately began looking around for a solution, but I couldn't find a straight answer.
The issue:
My question is, how do you encrypt a jar file, or at least encrypt the class file so that it isn't readable if you decompile it?
One solution I keep seeing is that you can obfuscate your code, but the issue with this is that your code still has to be able to run, and therefore the obfuscation can be reverse engineered with a little effort. The only other solution I could think of is having two separate jar files so that one of the jar files is encrypted and requires the other jar file to decrypt it. Now, before you say "they could just decompile the other jar and use it to decrypt the first jar". My idea was using a cipher that would be used to decrypt the first jar. In theory, the user could know the exact decryption method, but it would be completely useless without the secret word (cipher).
My question:
How would I implement this? I'm asking how do I run a jar file to encrypt/decrypt another jar with a user-specified cipher?
Feel free to give example code, I'm looking for any help I can get.
Thanks in advance!