Search code examples
javareverse-engineering

How can one make a Java program closed source?


How can a Java program be closed-source when the source code is easily retrieved through the use of jad or similar programs?

For example, a jar can be unzipped to get class files and these can be decompiled, read, edited and compiled again. So, how?

Because a proprietary license does not hide the code.


Solution

  • The best option you have is obfuscating your code before publicizing.

    The basic idea is to replace all "readable" names (say, "fetchTaxRate") with meaningless names as short as possible (say, "a"). If you have an instruction in your source "taxManager.fetchTaxRate(customerClass, countryID);" that might end up being "aB.e(zY, Q);" and anyone trying to decompile the binary will get to see the latter not the former.

    A good article on obfuscation is at https://www.excelsior-usa.com/articles/java-obfuscators.html

    The article also has a list of obfuscators and the one I use personally to my satisfaction (ProGuard) is among the list.