tags:

views:

125

answers:

4

I have developed a Java ME application for CLDC platform. It works fine when executed in an emulator. But when i deploy it to my N70 phone the application doesn't start at all in the phone. In my application there are some 14 classes and am creating an instance of each and putting them in the vector on application start. The classes just have one variable and 2 methods. Can this creating of lot of instances be the reason for its crashing?

Is there any way I can find out the reason why the application is not able to start in the phone?

Update: Its running fine on emulator. And one more thing I would like to mention is that- The code stops executing only at the point where am creating those 14 instances and adding them to the vector. Till that point the code executes fine.

+1  A: 

It might depend on where in the code you are creating those instances. If you are creating them in your MIDlet constructor or the startApp method try moving the initialization into the run method of your application.

One way of debugging J2ME applications that don't start on the phone is by adding "printf" style debug messages in your code to be written in the record store system and adding another MIDlet to your application to read from RMS and display those messages. Or you could just comment bits of code and see if it works.

tiz
I tried with both the constructor and the StartMidlet method. Both the places was causing the problem. One concern in inserting it in the running loop is that if that part is called again and again it may lead to lot of objects being created. I want them to be instantiated only once.
sana
+1  A: 

You can debug on device. If the emulator you are using is part of the Nokia SDK then there should be facilities elsewhere to carry out on-device testing and debugging. (I'd post more detail on this but I've only done this with Sony Ericsson phones recently.)

Another option is to use the Nokia tools that allow you to view the standard output and error for your application when it is running on your device (via Bluetooth for example).

martin clayton
Am using the Java ME SDK, using Netbeans for the development work. Thanks for the Nokia tool link. will go through it.
sana
+1  A: 

The probability that your application is actually crashing the Java Virtual Machine bytecode interpreter thread and terminating the whole native process is very small.

It has happened before but you need to eliminate several other potential issues before being convinced of an actual crash.

It is more likely that either:

  • Your MIDlet is not created or not started because the MIDP runtime decides it is not correct.
    or
  • Your MIDlet simply throws an exception that you don't catch, which can make it look like it was brutally terminated.

Since the MIDlet installer is supposed to prevent you from installing a bad MIDlet, the uncaught exception issue is more likely.

How to find an uncaught exception:

  • Start with the simplest HelloWorld MIDlet, using a Form so you can easily insert more StringItems at the top of the screen.
  • Create and start a new Thread in MIDlet.startApp()
  • In your override of Thread.run(), add a try{}catch(Throwable){} block.
  • Inside that block, do whatever your original MIDlet did.
  • Use the form as your standard output for debugging.

You can use Form logging to make sure you don't enter an infinite loop, to display exception classes and messages, to flag logical milestones, to display variable values...

That's the first step to figuring out what is going on.

QuickRecipesOnSymbianOS
Its running fine on emulator. And one more thing I would like to mention is that- The code stops executing only at the point where am creating those 14 instances and adding them to the vector. Till that point the code executes fine.
sana
I tired all of them. I dont think there's any other problem in the application until i get to the point where am creating 14 instances and adding it to a vector. Meanwhile I have removed the classes and instead using methods in a single class.
sana
A: 

Hi, I also faced a similar problem and when I recompiled my MIDLET as Midlet 1.0 then it worked fine. It seems like N70 is not able to run the new version of MIDLET. I think you downgrade and re-test your midlet.

Regards

Junaid

Junaid
will try that. For now I am kind of removed the lot of classes and object creation and instead taken the wrong route of doing it via methods :(
sana