why throws this exception:ALERT: Maximum byte code length (32kB) exceeded
Dear sir, I used Series 60 SDK with Jbuilder5 to run one of my MIDlet, but throws this exception on console window :
ALERT: Maximum byte code length (32kB) exceeded
why? by the way , my Jar file is about 300k.How can i solve this problem? I am anxious to reply. Thanks in advance!
RE: why throws this exception:ALERT: Maximum byte code length (32kB) exceeded
Probably because you have a class file that's bigger than 32k?
You need to optimise your code for size. Here are some tips, but if you search this forum and the J2ME related ones you should find some more comprehensive tips.
1) Use a code obfuscator/compressor, something like JODE or RetroGuard. This will reduce the size of your class files for you.
2) Learn what code constructs in Java take up lots of class file space. Static strings and static arrays are 2 big size culprits. Always place all the data you can into seperate resource files and load the strings and arrays up at runtime.
3) If you're targeting a Nokia phone specifically (like the 7650), look at using the Nokia UI DirectGraphics class for images. This way you can store your image data in a raw format that gets compressed in the jar file, rather than PNGs which are not very well compressed.
4) Reduce the overall number of files in your jar file. Each one add overhead to the zip file structure.
Hope this helps,
Re: why throws this exception:ALERT: Maximum byte code length (32kB) exceeded
Thank you for your posts, they helped me much.
I had this problem with arrays. If I add array to my class then emulator crashes with this message. I removed an array and it run. But I had enourmas (above 3000 lines) class (bacause I should save space).
If you have such problem be very carefull with last changes . Any limit is exceeded (metod length, size of arrays ,etc). I just exctracted my arrays and now i'm loading them from data files.