Where 2 place files for J2ME Loading

Started by
14 comments, last by steg 19 years ago
I dont know where 2 plac ethe files within my project directory so that the sprite data is beeing loaded when the app runs. I always get an IO error. Where do I need to put the files!? Also how can I make 1 build file so that when its dont I can upload 2 my phone!?
Advertisement
usually in the res driectory.

eg:

/WTK21/apps/[Project Name]/res/



Thanks for the quick reply :)
The app folder isnt there, im using Eclispe as IDE. The folder tree looks like this:

../<APP>/......../........./Main.java......../Canvas.java......../Sprites/................/Sprite.png................/Player.png......../Tiles/................/Water.png................/Wall.png
Sorry for the delay, had classes to go to [depressed]. I personally have never tried using Eclipse for J2ME, but with your dir structure the code should be something like:

Image.createImage( "./Tiles/filename.png" );

or

Image.createImage( "./Sprite/filename.png" );

If youy could post your image loading code it might give a clue. you could also open up the JAR (You can use WinZip etc for this) that is created and make sure the images are being put in there by the compililation process.

--

Oh yeah, your other question!! J2ME requires two files usually a JAD and a JAR, these can both be uploaded to the phone in various way (Data Cable, Infrared, Bluetooth and OTA (Over The Air - WAP, GPRS etc).

If need to deploy the app to your phone OTA, just set up a websever (Apache or IIS both work). You need to edit the MIME types, but then you can download OTA from your own PC. You don't need a fast connection for this (I did it on a 9.6Kbps connection before!!).

Keep posting here if your still stuck, I'm assuming you're fairly new to J2ME stuff, and it can be confusing at first with all the quirks and other crap this API has!!
A strange thing happend yesterday, well actually it isnt that strange at all but the code I have and the dir structure I was useing was correct after all. The problem was that I had made the changes in the files/folders in Windows Explorer. Eclipse caches the data into a "verified" folder and builds the midlet from there. So if you havent made any changes in the code or added folder 2 the project inside Eclipse it wont notice the files or changes in the folder.
The dir stucture remains the same as posed above and the code for loading the images looks like the one you posted Image.createImage( "/Sprite/filename.png" );

The project has a JAD file and it contains an netry for the JAR file like this: J2MEGame.jar, I have searched my HD for the file and I cant find it.

hihi yes im fairly new to J2ME, I have worked with Java be4 but it's been a few years now :p

Edit:

I think I have found it, Eclipse has an option under file > Export > JAR File and in here I can select the project and what and how I want 2 export it.

Well I got my JAR file but when I try 2 run it (by doule clicking the file) I get an error message : Failed to load Main-Class manifest attribute from J2MEGame.jar

Thanks for helping :)

[Edited by - D3DXVECTOR3 on March 9, 2005 2:00:11 AM]
I fixed the main-class thing by building the jar via, right clicking the project and then select J2ME > Create Package. It then creates the jad and the jar file. Now when I double click the jad file the emulator is launched, but now I see the different classes 2 instead of running the midelt from the mainclass.

[Edited by - D3DXVECTOR3 on March 9, 2005 8:28:50 AM]
I'm not quite sure what you mean exactly by the above, can you clarify.
In Eclipse you can rightclick on a project en you'll see an option J2ME > Create Package. This will build the jar file and place the jad in the same folder as the jar file.

When I run this build via the jad file it starts the Midlet with no error. The emulator is started and instead of running the midelt like it did in via Eclipse it shows a list of the classes in the jar file.

|----------------||----------------||MainMidlet      ||GameCanvas      ||AnotherClass    ||AnotherClassA   ||...             ||...             ||                ||----------------|


I can select any of these classes and it will try to run it. When selecting classes other then MainMidlet the midelt creates an exception, for obvious reasons.

Hope this cleares it up.
You are ruuning in the emulator right? I reckon, but am not sure, it's compiling each class into individual midlets. Thats the only reason you would be presented with a list of separate classes that are all meant to be in the same application.
Why is it compiling each class into individual midlets!? What did I forget something!?

Edit:

I have found out why. When I added the new classes I added them as midelts and then cleared the file and defined my own classes. Eclipse keeps an track on what and how and backs it up and uses that instead of checking what changes and what didnt.

Eclipse is one of the worst IDE tools I have ever used.
I HATE ECLIPISE!!!

[Edited by - D3DXVECTOR3 on March 14, 2005 7:20:14 AM]

This topic is closed to new replies.

Advertisement