Java Reference
In-Depth Information
try {
} catch(Exception e) {
7.6.3 The Big Squeeze
The biggest hurdle with DoJa development for those of us who use the
overseas versions is keeping your JAR size below 30 KB. It turns out that
JAR size varies directly with the number of classes used, the number
of methods in those classes and the length of the identifiers used for
methods, fields and classes (yes, really!). This is where the use of an
obfuscator such as ProGuard 10 can be a real life saver.
Originally designed to help protect intellectual property, an obfus-
cator can shrink classes dramatically by shortening names of packages,
classes, methods, fields and variables. They can also add a number of
optimizations while allowing you to work from a code base that can be
In terms of your code base, don't fall into the trap of trying to manually
optimize your classes - the rule of thumb should be to let an obfuscator
do this for you. Re-architecting an application to satisfy an external
constraint such as this moves your focus away from realizing a correct
software solution and starts to reduce your approach to the level of
a hack.
As an example, if you configure Eclipse to use ProGuard as an
obfuscator, the executable size drops down to 8.79 KB from 10.7 KB - a
reduction of just over 17%. For a simple application, this is more than
enough and, in many cases, reductions of up to 20% are common.
You can further reduce the size of any Java binary by optimizing
resource management - for example, large resources can be downloaded
from remote servers when required rather than being bundled in with the
JAR file. If you need to keep resources locally accessible, you can look
at reducing their sizes - for example, an image may still be acceptable in
your application with less color depth or at smaller dimensions.
7.7 A Safe Port
There are a number of issues to be addressed when porting an application
from MIDP across to DoJa. While they're both built on top of CLDC, the
Search WWH ::

Custom Search