Saturday, April 26, 2008

Obfuscating a NetBeans Java application project

Some time ago I found a couple of posts talking about how obfuscating a NetBeans RCP module (here and here).

Getting some parts of the ant targets presented in the previous post, this one present a simple target that allows to obfuscate a normal java library.

For this, you need to have installed the obfuscator ProGuard.

Take into account I am talking about obfuscating a Java library. This implies the obfuscation is lighter than if you obfuscate a closed application, that is, all public methods and interfaces must maintain its name (if not you can call your library methods anymore).

Open your build.xml Java application file and paste this target:






classpath="${proguard.jar.path}" />



renamesourcefileattribute="SourceFile" ignorewarnings="true">




























name ="class$"
parameters="java.lang.String" />
name ="class$"
parameters="java.lang.String,boolean" />











type="**[]"
name="values"
parameters="" />
type="**"
name="valueOf"
parameters="java.lang.String" />






type ="long"
name ="serialVersionUID" />
name ="**"/>
name ="**"/>
name ="**"/>
type ="void"
name ="writeObject"
parameters="java.io.ObjectOutputStream" />
type ="void"
name ="readObject"
parameters="java.io.ObjectOutputStream" />
name ="writeReplace"
parameters="" />
name ="readResolve"
parameters="" />








Special attention to these couple of lines:



Tuesday, April 08, 2008

Curious ?