There is a strange error in Samsung phones. When you try to launch a midlet the phone displays the message "Java Error: Invalid format".
This means the virtual machine can't load the classes of the midlet. It could be:
- the classes are not preverified
- the classes are corrupted
- the classes are ok but the VM can't load them, because an exception is launched while they are loading..
We will focus in the last option. Why a class can't be loaded and how to fix it?
- Sometimes we write some lines of code in the midlet constructor. But this lines can have method calls to other classes and so on, and all classes must be loaded BEFORE the midlet is initializad. If the midlet is not initialized it can't manage well things like screen.getWidth and getHeight, etc. Avoid method calls in the midlet constructor.
- Other cause can be to write method calls in static blocks or static variables. It's the same problem than before, lots of things must be loaded BEFORE the midlet is instantiated.
So, now the midlet is instantiated before the classes are loaded. Now the error "Invalid Formatd" shouldn't appear. Your phone must launch now an exception or anything similar.
E.g: Samsung S8000 Jet. This phone has a problem in some firmwares. The method Font.getSize() returns a non standard value, and when you want to obtain a new font using the size returned by Font.getSize() an exception is launched. If this code is called by the constructor block an exception is thrown before the midlet is instantiated, so the error "Invalid Format" is displayed.
I worked with lots of samsungs and generally the solution is the same. Avoid coding in the constructor to find easily the errors.
I hope it works for you.