Search code examples
javaintellij-ideajarobfuscation

How can I obfuscate a jar in IntelliJ?


I found out that an executable jar file can be decompiled to retrieve the original source code using Java Decompiler, which allows decompiling and browsing the source with the JD-GUI.

I'm trying to obfuscate a jar file to protect it from retrieving the original source code.

I have tried proguard but sounds a little bit time consuming!! I then tried IntelliGuard 2 plugin but there was no information about what proguard and yguard and how to use them!!

I read some resources that I need to generate an Ant build file for proguard or yguard to be able to obfuscate the jar file. Then I stuck a little bit on generating a jar file to obfuscate.

Is there an easy and straightforward way to generate a jar and obfuscate it?


Solution

  • I have been trying to obfuscate a jar file to protect it from retrieving the original source code.

    Obfuscation in Intellij requires IntelliGuard 2 plugin and yuguard 3.0.0 (preferably yguard-bundle-3.0.0.zip).

    The obfuscation process :

    1. Generate Module out of the project: File --> project settings --> Modules ( + new module and set proper out path)

    2. Generate jar file using Artifacts: File --> project settings --> Artifacts ( + JAR and naming configuration)

    3. Generate Ant build

    4. Obfuscate the jar file: File --> project settings --> Facets( + Obfuscation ), then choose the path to ygurad-bundle/lib/yuguard.jar, and choose the main class. See illustrating image below:

    enter image description here

    Afterward, build Artifacts (build--> build Artifacts), then Obfuscate the jar file ( build--> obfuscate jar, then choose the input jar and the output obfuscated jar).

    I couldn't find another way or resource to follow and do it the easy way, so I decided to share my experience.