FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Discussion
   General Processing Discussion
(Moderators: fry, REAS)
   obfuscation rocks
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: obfuscation rocks  (Read 4717 times)
toxi

WWW
obfuscation rocks
« on: May 13th, 2004, 4:30pm »

i started using the free & fabulous ProGuard java byte code obfuscator for my current work project and managed to shrink the exported applet filesizes down to under 45%, which absolutely rocks!
 
eg. base26 original jar: 141K -> obfuscator -> final jar: 72K (51% of original)
my new project original: 120K -> 51K (42%)
 
for those of you who also started using eclipse & ant, i've updated the existing build XML file to support proguard as optional, post-compile action when exporting your sketch as applet. the new file can be found here:
 
http://www.toxi.co.uk/p5/eclipse/build.xml
 
before you can start using proguard from within eclipse, you'll need to perform the following steps first:
 
* download & install the latest version (2.1 as of writing) in a location of your choice
* in eclipse, open window > preferences > ant > runtime. in the "classpath" tab, select "add jar..." and then select the file "proguard.jar" from the /lib folder inside the main proguard folder you've just installed
* overwrite any old build.xml in the eclipse workspace with the new version from above
 
you should now be ready to run the new ant export script.
 
btw. the obfuscation step only executes if ProGuard is available & properly set in the ant classpath. if it is, the original .jar file of the applet will be renamed and will still be available later, just in case something went wrong with crunching the code. though, the index.html wrapper will by default link to the obfuscated file. it's all quite pretty straight forward, you'll see...
 
alternatively, you can also run proguard from the command line (or its GUI version) to process normal PDE exported jar's. just have a look at the manual on their site...
 

http://toxi.co.uk/
Quasimondo

WWW Email
Re: obfuscation rocks
« Reply #1 on: May 13th, 2004, 7:29pm »

Wow that sounds brilliant - thanks for sharing this!
 

Mario Klingemann | Quasimondo | Incubator | côdeazur
Quasimondo

WWW Email
Re: obfuscation rocks
« Reply #2 on: May 15th, 2004, 5:51pm »

Do you know the correct settings for the ProGuard config file if an applet uses Sonia? It looks like the standard settings are not sufficient in this case. Probably it needs some "keep public class..." entry.
 

Mario Klingemann | Quasimondo | Incubator | côdeazur
Quasimondo

WWW Email
Re: obfuscation rocks
« Reply #3 on: May 16th, 2004, 7:00pm »

Somehow when I try your build.xml I always receive a java.lang.NullPointer error after the obfuscation step. When I use the same syntax on the commandline it works just fine.
 
Maybe there's a problem with my general pathes. Anyway - i've got it working now after I changed this part of the build.xml a bit:
 
Original:
Code:

<java classname="proguard.ProGuard">
  <arg value="-injars ${temp_jar_file} -outjar ${final_jar_file} -libraryjars ${JAVA_HOME}/jre/lib/rt.jar -keep public class ${project_name}" />  
  </java>

 
This works for me:
Code:

<java fork="true" jar="C:\Programme\proguard2.1\lib\proguard.jar">
  <arg value="-injars ${temp_jar_file} -outjar ${final_jar_file} -libraryjars ${JAVA_HOME}/jre/lib/rt.jar -keep public class ${project_name}"/>
   </java>

 
Of course you would have to exchange the line "C:\Programme\proguard2.1\lib\proguard.jar" with the path to where you have installed ProGuard.
 
And I think it's important to mention again that the name of the main class has to be the same as the name of the project (I know - you wrote that in the other thread, I'm just repeating it as I forgot that in my first attempt.)
 

Mario Klingemann | Quasimondo | Incubator | côdeazur
Pages: 1 

« Previous topic | Next topic »