midlet not launching in emulator

Started by
19 comments, last by scorpN 17 years, 11 months ago
Hi there guys, I'm hoping somebody may have an answer for me here, I'm quite new to mobile development, so excuse any mistakes! I'm using Eclipse, J2ME polish, WTK2.2, and Ant to build my game's .jar and .jad files for multiple handsets. I have a J3D implementation and a 2D implementation of my game which I am hoping to build from the same source using Polish's handy preprocessor directives. I've got it all set up, and when I do a build and run within Eclipse, the midlet runs the 3D implementation with no problems (like it should do). When I try an Ant build it spews out the jars and jads (Generic/midp1, Generic/midp2, Generic/multi) with no errors. The problem is, when i try to execute one of the .jad files created with the Ant build, the emulator pops up, shows the name of my game and the 'launch' option (set to the right soft key.), but nothing happens when I press 'launch'. It just seems to hang there since it doesn't quit the emulator, it just stays on that screen. This happens with all three of the builds created (midp1, midp2, multi). Has anyone come across this before? Obviously I'm doing something wrong. Does it sound like a setup problem? Or maybe I've made a mistake with the preprocessor directives (I've done that before)? Anything that points me in the right direction would be great!
Advertisement
Does the path to jad & jar contain any spaces, umlauts or other non-alphanumeric characters? Is it on a network share or network volume?

This caused us a lot of strange problems with some emulators.
hmmm, actually they do contain non alphanumeric characters. I'll just do a quick test to see if that sorts it out...

No that hasn't fixed it :(

its not on a network share/volume, its all coming from my PC, although the source code is checked out from a CVS, but since I've 'got' all the files on my computer, and these are the ones being built, I wouldn't have thought that would be an issue (although with my current experience with mobile games development, nothing can be ruled out!)

Oh, some more information, when I run one of the jars on a handset rather than in the emulator, it seems to try and start but then crashes/quits.

(I'm currently struggling with the debugger in Eclipse to try and work it out, its rather alien to me.)
Are you using any device/carrier specific APIs? That could be your problem.

Also, if you can create a bat file to run your builds from, or run it from the command line you can see the console output. The output will tell you if the build is just crashing on startup or not running at all.
thanks trojanman, i'll try to get it running with command line and let you know how it goes
Can't really tell from your post if you have gotten something to work previously, but one problem I had when starting with midlets was that I made a main-loop like on a PC:

void run() {
while(true) {
// do stuff
// paint stuff
}
}

But in the midlet it should be (this is assuming you have made a new thread for your app, which seems to be the way to go)

void run() {
while(true) {
// do stuff
// paint stuff
Thread.sleep(50); // 50 or whatever...
}
}

I quess because the mobile doesn't have a proper thread scheduler, so you have to yield manually.
Thanks for the reply Hesterumpe, I've set up my midlet with the thread sleep so i don't think thats the problem, but thanks anyway!

Well I think I've dug up a big clue which hopefully should allow you guys help me. :)

When I try running the Jar directly (by double clicking it), or the Jad from the command line, I get a different error for each case, but they look like their trying to tell me the same thing:

Double click the jar:
"Failed to load main class manifest attribute from C:\path_to_my_jar"

Run the Jad from cmd:
"Exception in thread "Main" Java.lang.noClassDefFoundError: Game/jad"

Ive had a (very quick) look around and it seems to me like I need to specify the main class in the jars manifest file. I also get the feeling this only has to be done for MIDP1? MIDP2 doesn't need to specify the main-class attribute?

I'm going to keep looking for info, but don't be shy if you've got a golden nugget of info!

(EDIT: at this point I'd just like to reiterate that if i build and run from withing Eclipse the game runs in the emulator fine. I can also create a package from within Eclipse and the resulting jar will run on a mobile device. The problems occur when I try to do an Ant build using J2ME Polish to create multpile jars for different handsets)
maybe you have a problem with MIDlet-1 in your manifest.mf file - the class name is wrong or something. maybe post the manifest.mf.
Why don't you use a compare tool to compare the working version with the non working version?

It looks like you have a file reference which is pointing to the wrong place, In you ant version you may be putting files in different places or changing the contents of the jad file.

Greig
Are you sure it's hanging? Have your midlet do a println in the very first line of the init function. It could just not ever be drawing.

This topic is closed to new replies.

Advertisement