english português


search
login   |   sign up   |   buy
     
Downloads
  Documentation
  Bug reports
  Changelogs
  Support
  Compatibility







Tips and Tricks / Details

Aug 18 | How to compress and protect your programs with Proguard

  The Java compiler inserts, in a class file, informations that will help the debugger work, like the class/method/attribute names. However, these informations allow a decompiler create another JAVA file almost identical to the original file, containing everything except the comments. At the same time, these informations increase the class file size.

To help protect your programs, and also shrink it up to 60%, you can use programs known as Code Obfuscators. There are many in the market, and one of the best is Proguard, which is distributed with the SuperWaba SDK, placed in folder SuperWabaSDK/bin/tools/obfuscators. Note that the decompiler will not prevent the program decompilation, but will make it rather incomprehensible and most of the times will break its compilation.

To use it in your program, you must:
  1. Create a JAR with all the files that comprises your application, including the class files, bmp, wav, txt, etc.
  2. Pass this JAR file through Proguard, which will create another JAR with the obfuscated classes. Important: you must make sure that the class that extends MainWindow is not obfuscated, otherwise, the virtual machine will not be able to run the program!
  3. Pass the output JAR to Warp, which will generate a PDB with its contents.
Next we see a sample used to create the VPFinance program:
 
jar cvf before.jar versapalm/finance/ *.class leftarrow.bmp sw_logo.bmp *.txt
java -jar \SuperWabaSDKPro\bin\tools\obfuscators\proguard.jar 
    -libraryjars \SuperWabaSDK_LGPL\lib\SuperWaba.jar -injars before.jar 
    -outjars after.jar -keep public class versapalm.finance.VPFinance 
    -overloadaggressively -defaultpackage -allowaccessmodification -ignorewarnings
java superwaba.tools.Warp c /t VPFinance after.jar
Or, if you want to do this using an ANT file:
<taskdef name="proguard" classpath="bin/tools/obfuscators/proguard.jar" 
    classname="proguard.ant.ProGuardTask"/>
<proguard shrink="false" defaultpackage="" optimize="true" obfuscate="true" 
  overloadaggressively="true" verbose="true" ignorewarnings="true">
    <keep name="${app.name}" /> <!-- superwaba.samples.ui.UIGadgets" -->
    <keep access="public">
      <field  access="public protected" />
      <method access="public protected" />
    </keep>
    <libraryjar file="${sw.jar}" />
    <injar path="${in.jar}" />
    <outjar path="${out.jar}" />
</proguard>
 

Go read other tips

 

Copyright© 2002-2009 SuperWaba20 userssite map