Today I was asked about obfuscation. In fact, the question was "how to obfuscate code in NetBeans". Well, code in NetBeans is like any other Java code anywhere else. And others have had the same need. I looked into it and came up with the following:

  1. Download ProGuard.

  2. In your build.xml, add the target outlined in this handy FAQ: Can I obfuscate a module? Just make sure to replace ${proguard.jar.path} with the full path to the proguard.jar, which can be anywhere. Also remove the dependency on init target, in the obfuscate target outlined in the above FAQ.

  3. Build your application. When you do so, the Output window shows that ProGuard writes a new folder with your own module's obfuscated classes:

  4. Look in the folder indicated above and there's the 'obfuscated' folder with the obfuscated classes:

Next I tried to decompile the classes, but all 3 of the decompiler plugins in the Plugin Portal failed me. But, if one wanted to decompile, there are many decompilers out there that could be used. The point is that obfuscation is not difficult to achieve, via the handy Ant target above. And, it's clear that if you have some top secret code that you need to obfuscate, there's a well trodden path that you can follow.


I used ProGuard, with JDK6 code, some time ago and all decompilers I used failed. It seems a problem about JDK6 bytecodes and the decompilers.

Posted by asantiago on January 31, 2008 at 02:57 PM PST #

surely that's a good thing?

Posted by guest on January 31, 2008 at 04:24 PM PST #

You're a funny man, :-) Or maybe you're a woman. Woo... you obfuscated your gender. :-)

As for me, and asantiago, we'd like to decompile our code so that we can see that we've obfuscated it correctly. But, you're right, if we're able to decompile it, then the obfuscation is less obfuscated than now that we've failed to do so.

Posted by Geertjan on January 31, 2008 at 05:43 PM PST #

Nice post Geertjan ..thanx!

Posted by Paris Apostolopoulos on January 31, 2008 at 10:17 PM PST #

Is it possible to configure Proguard for a GWT based project?

Posted by Kevin Tarn on October 28, 2008 at 07:45 PM PDT #

Is there a zelix(ZKM) maven plugin that you guys know of?

Posted by dawit on May 06, 2010 at 06:45 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« July 2016