ProGuard is an application shrinker/optimizer/obfuscator for Java applications. It can be used from the command line or from your favorite IDE, such as Eclipse or NetBeans. ProGuard is an important tool in your MIDlet development toolbox.
The recipe for obfuscating your MIDlet and Microlog is as follows:
- Select Window -> Preferences
- Select the Java ME -> Packaging -> Obfuscation
- Press the "Browse" button and select the directory where you installed ProGuard.
- Select Project -> Properties
- Set the dialog to the value according to this screenshot:
- Select "Java Build Path"
- Select the "Order & Export" tab. Check the Microlog jar like this
- Select your project. Bring up the context menu (in Windows it is done by a right click). Select "Mobile Tools for Java" -> "Create Obfuscated Package". You should now have an obfuscated jar in the /deployed directory. If you run the project as a "Emulated Java ME JAD", you automatically use the obfuscated jar file.
For those of you that are not using Eclipse, you could use the following configuration when running ProGuard from the command line.
-keep class net.sf.microlog.appender.MemoryBufferAppender
-keep class net.sf.microlog.appender.ConsoleAppender
-keep class net.sf.microlog.format.PatternFormatter
Copy the content and save it to a file, for example proguard.conf. Then you start ProGuard like this:
java -jar proguard.jar @proguard.conf.
By using ProGuard you reduce the size of your MIDlet jar. Unnecessary classes are removed, the code is optimized and obfuscated. And using Microlog does not mean lare overhead to your MIDlet. There are other alternatives to ProGuard, but ProGuard is the most widely and de-facot in the lovely world of Java ME.