Search code examples
javajardecompilingcopy-protection

How to protect a Jar file from being decompiled?


I'm developing an application using java but I'm not going to release the code. The problem is, I tested one of these jar de-compilers and it was able to get the code from my jar file almost perfectly! My question is how can I distribute my jar file without my code being extracted from it?


Solution

  • As Java preserves most of the "metadata" during compilation (which allows dynamic loading and reflection), it is a straight forward to decompile (not only disassemble) the compiled class files. That's why the recovered code is very similar to the original.

    While not perfect, your probably only option is to use an obfuscator, such as ProGuard.