I am building a JApplet that has to be embedded on a 64KB partition. So far I have enough space, but I am wondering if you can give me some great tips on how to make my jar file smaller. I am reusing code as much as possible and compressing jar file when compiling. Thank you all.
Asked
Active
Viewed 265 times
3 Answers
1
Since size is going to be the prime concern, you should try avoiding as much as external dependencies/libraries. Even if you require them, you have to be picky, probably go and add which ever is very much custom required to your application. And thus make sure only Java Foundation classes are used.

bragboy
- 34,892
- 30
- 114
- 171
1
Read the examples for Proguard. It has flags that shrink the size of your bytecode. Take a look at this article as well.

Amir Afghani
- 37,814
- 16
- 84
- 124
1
Two things I would definitely do:
- Obfuscation will make all names (classes, variables, methods) shorter
- Don't compile any debug info into your classes (javac -g:none, or equivalent option in Ant/Maven whatever you use to compile)

Oleg Mikheev
- 17,186
- 14
- 73
- 95
-
What app for Obfuscation would you recommend? Are they safe to use (can they break my code)? – jadrijan Dec 14 '11 at 15:05
-
I have just tried javac -g:none and it has reduced my jar file from 58KB to 45KB...wow, thank you very much. – jadrijan Dec 14 '11 at 15:13
-
1I can't recommend any since I haven't used one for like 10 years... there are discussions available like [this one](http://stackoverflow.com/questions/310533/java-obfuscators) and it seems that ProGuard should be good but watch out for possible optimization issues – Oleg Mikheev Dec 14 '11 at 15:35