J2ME: How to optimize JAR file size
Anybody who has developed mobile application using J2ME must already know that getting the smallest JAR file size is very important.
This is because the limit imposed by the mobile phone devices due to storage/memory limit on small devices. It is not unusual for you to get mobile devices with 32KB ,64KB or 256KB jar file limit.
This is where JAR file optimization is crucial for deploying your J2ME mobile application out in the wild. Here's a few thing that you can do to reduce your JAR file size :
Optimise PNG files
PNG is a graphic format used primarily by J2ME devices, and is guaranteed to be cross-platform between mobile devices that implements J2ME.
The best part with PNG file is that its bitmap data is compressed using the deflate compression algorithm which can be easily optimised by easily obtainable tool :
Obfuscation
Obfuscation does help in chopping unecessary code, renaming long variables and classes, thus making the class files smaller. Don't forget to Obfuscate your package files before deployment.
It does not only protect your code, but it does save a lot of valueable space.
Proguard and RetroGuard is the most common obfuscator used in J2ME application
Recompress JAR files
Finally, after going through optimizing PNG files and obfuscating, you might want to try to recompress your JAR files using a tuned JAR compressor which favors size over speed. For this purpose, I prefer using KJar, a JAR file recompressor based on Ken Silverman's KZIP.
This final step combined with previous optimisation will greatly reduces your JAR file, personally I've achieve 33% space saving by reducing my resulting JAR file size from 80KB to 53KB (27KB saving !)
Please visit SupremeJ2ME website for more information about optimising your J2ME application for size.
[tags]j2me,javame,mobile,jar,java,nokia,programming,optimization[/tags]
April 4th, 2007 at 5:01 pm
[...] J2ME: How to optimise your JAR file size Optimise PNG files. PNG is a graphic format used primarily by J2ME devices, and is guaranteed to be cross-platform between mobile devices that implements J2ME. The best part with PNG file is that its bitmap data is compressed using the … Related: • J2ME • How • to • optimise • your • JAR • file • size [...]
June 19th, 2007 at 8:20 pm
Kjar has virus !!!
August 21st, 2007 at 6:55 pm
According to Norton Internet Security, KJar has some sort of Trojan in it.
Pity, since it took about 5% off a jar file.
The Supreme J2ME web site is down at the moment so that might be the end of KJar.
September 9th, 2007 at 4:52 pm
The application decompress KZip application that it uses during runtime, that is what triggered the Anti-virus alarm as the same technique is being used by trojan application.
October 4th, 2007 at 10:05 pm
[...] J2ME: How to optimize JAR file size : Mobile Programming Pit StopAnybody who has developed mobile application using J2ME must already know that getting the smallest JAR file size is very important. … [...]
December 8th, 2007 at 11:14 am
The Supreme J2ME web site just posted last January 2007 that antivirus companies have been notified about it. It’s not a trojan or virus. It just has a signature like one because of the overwriting thing it does.
November 17th, 2008 at 3:55 am
thanks for share information. this site is very nice.
for java hacking try visit here
sory my english is bad
January 11th, 2009 at 3:10 am
thanx for nice article…,good job dab..
@ pangeran kodok
March 22nd, 2009 at 4:58 pm
good2.
July 19th, 2010 at 5:46 am
Just purchased a Mythic for myself and will be having one particular for my wife quickly! It has just the appropriate mix of features. just brief of a complete smartphone. I’m preserving an eye about the Captivate for a potential future cellphone..
.selling prices are way as well higher when released. I’ve been in high tech for 20+ many years and fundamentally hack almost everything I own to produce it superior laptops, GPS, automobile navigation systems, and so on. and yes cell phones as well. Within the handful of days I’ve owned the cellphone I have currently set up Opera Mini, Bolt 2.1, freecaddie, Google Maps w/GPS functionality, deleted all locked useless apps after backing them up and absolutely modified the menu process to my exact requirements devoid of all ineffective apps.
July 28th, 2010 at 8:37 pm
Interesting site man Thank you
July 28th, 2010 at 10:31 pm
Thanks, nice post