Search code examples
javajarobfuscationdecompilingcopy-protection

Can we reveal the source code of a software from its setup file?


I found that we can read the software source code of a JAR file by using de-compiling software. I downloaded such a software and read lot of such codes.

My questions are...

  1. How can we prevent decompiling our class files which is inside the JAR?
  2. Can anybody reveal the source code of a software from its setup file(not the JAR)?

I know that There are some answers for the first question on the internet. But I appreciate if you can explain it more explicitly. But the second question is the most important one for me.


Solution

  • You cannot completely prevent decompilation. But you can make this much harder.

    Use obfuscation - process that changes your byte code making it very hard to understand. There are a lot of java byte code obfuscators. Some of them are free.

    But the code still can be de-compiled. You can also store your classes in password protected zip file. But java by default does not support such files. You can however develop your own class loader and separate your application into 2 parts. First, small loader that just starts the application, then loads majority of classes using custom class loader that loads classes from password protected zip.

    You can also load part of your application from internet over https, so it will be really hard to hack it.