Search code examples
javaobfuscationproguard

How to obfuscate Java code quickly?


How to obfuscate code quickly. I have a very small Java App and I want to deliver the obfuscated code to my client. I have heard a lot about ProGuard to obfuscate code and have downloaded it but doesn't know how to obfuscate my "abc.jar" file.

I checked out its website but it contains a lot of material to read. I don't need heavy obfuscation. I just need a obfuscate that simply changes the name of variables, methods and classes to some unreadable ones. I know ProGuard provide all of this with a ton of other functionalities too.

Q1. So could anyone tell me please some simple obfuscators or some simple steps to use proguard so that I can just input "abc.jar" and it outputs "obfuscate_abc.jar" or something simple like that.

Q2. One more thing, as my Java program uses external libraries, so should I need to obfuscate those libraries too?

Q3. Is there any Eclipse or NetBeans plugin availabe to this obfuscation?

I have also heard that we should retain the mapping table file with us so that in future we can debug or edit that obfuscated code by first de-obfuscating with the help of that mapping-table which was created at the time of obfuscation.

Q4. So, one more question is Why do we need to keep that mapping-table with us? We can simply retain a copy of un-obfuscated application so as to make changes in that (if required in future). Is there any reason to retain that mapping-table file with us?


Solution

  • Q1. So could anyone tell me please some simple obfuscators or some simple steps to use proguard so that I can just input "abc.jar" and it outputs "obfuscate_abc.jar" or something simple like that.

    Just go for ProGuard, it's definitely a good tool (recommended in many answers here on SO like this one, this one and this one).

    Q2. One more thing, as my java program uses external libraries, so should i need to obfuscate those libraries too?

    No need IMHO (not even mentioning that you may not).

    Q3. Is there any eclipse or netbeans plugin availabe to this obfuscation?

    I'd rather suggest to use the Ant Task or the proguard-maven-plugin. See this question about the maven plugin if required.

    Q4. So, one more question is Why do we need to keep that mapping-table with us. We can simply retain a copy of un-obfuscated application so as to make changes in that (if required in future). Is there any reason to retain that mapping-table file with us?

    Yes, to "translate" stacktrace.