Gemalto is now part of the Thales Group, find out more.

You are here

Thales IoT Developer Community

How to obfuscate my Java Code. Benefits

FAQ, March 6, 2014 - 1:13am, 8325 views

Using an obfuscator with your j2me applications is convinient to be able to “obfuscate the code”, and to reduces the total “.jar” file size generated.

Take in consideration that you are programming an embbeded processor with small RAM and FLASH memory compared with a desktop computer.  

Using an obfuscator will reduce the use of FLASH memory, and especially the RAM memory.

To provide an idea, an application example takes around 130Kb without obfuscating and 80Kb obfuscating. You can see that the reduction is quite significant.

Where you can download an obfuscator:

http://sourceforge.net/projects/proguard/files

Once the file has been downloaded then unzip it inside your Eclipse folder, for example

c:\Eclipse\proguard4.5.1\

Then under Windows > Preferences > J2ME > Packaging > Obfuscation you can select the PATH:

 

Proguard

Once selected, you can “compile” your file obfuscating it. Instead of making a “Create Package”, to do this we make a “Create Obfuscated Package”.

"it works, but an obfuscating error appeared"

This is because you need to specify the complete path to the JDK and you probably have a JRE. Under Window > Preferences > Java > Installed JREs you can select the appropriate JDK directory. In this case:

Proguard-1

 

Hi ! Does the obfuscated code run faster or is there no difference?

Antero Markkula
Communication and Mechatronics

Enkom Active Oy – www.enkom-active.fi
Upseerinkatu 3 A, 02600 Espoo, Finland
Mobile: +358 400 411368
Office: +358 10 204 0000
Fax: +358 10 204 0010
E-mail: antero.markkula@enkom-active.fi

Hi Antero,

The ofuscated code is always smaller than the original code. That's, the code needs less memory and run faster

Regards

Antonio

Somewhere over the rainbow!!! Looking for the Oz Land!!!

Author

Alopez's picture
Alopez