Java performance and optimization - Size
How to reduce the size of your .class files?
Here is a list of tips.
Don't initialize big arrays
Compiler doesn't perform any optimization. This example shows that the compiler inserts one element at a time. This becomes critical when the size of the array is big.
String [] a={"1","2","3","4","5"};
00000000 bipush 9
00000002 anewarray java/lang/String
00000005 dup
00000006 iconst_0
00000007 ldc "1"
00000009 aastore
0000000a dup
0000000b iconst_1
0000000c ldc "2"
0000000e aastore
0000000f dup
00000010 iconst_2
00000011 ldc "3"
00000013 aastore
00000014 dup
00000015 iconst_3
00000016 ldc "4"
00000018 aastore
00000019 dup
0000001a iconst_4
0000001b ldc "5"
0000001d aastore
Use obfuscators to reduce your class variables names and to remove debugging information
Use JAR files or
Jar files are stored in the ZIP file format. You can create them using the jar tool included with the JDK 1.1.
This page was last updated 06 March 1998