How to specify path to a resource?

I have a MyMIDlet.java file and "pole.gif" image on the same folder. Now I compile and run them as follows:-

javac -bootclasspath /opt/midp/classes MyMIDlet.java

preverify -classpath /opt/midp/classes:. -d . MyMIDlet

midp -classpath /opt/midp/classes:. MyMIDlet

I get the following error:-

java.io.IOException

startApp threw an Exception

On debugging I found that this error is caused by this line:-

ballSprite =new Sprite(Image.createImage("pole.gif"));

I also tried replacing the argument with "/pole.gif", "./pole.gif", "/home/smith/midlets/Test/pole.gif", but nothing worked.

However with NetBeans 5.5 it works with "/pole.gif". Any suggestions how I can make it work with the command line midp tool?

[832 byte] By [Nortona] at [2007-11-27 6:27:12]
# 1
check out the source code used in the Sun WTK examples (like UIDemo) to see howto access to a resource...
suparenoa at 2007-7-12 17:48:57 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 2

supareno, please do me a favour. please do not reply to threads i post. i have seen your reply in another thread also and they provide no useful information. it's a humble request. of course you are free to not grant my request. it's your call.

I have explained in the my original post that I know how to specify the path of a resource and it works well with NetBeans as well as WTK. However the same paths do not work when I try to test my program using the "midp" command in the command line.

looking forward to know why the same paths do not work in case of midp. is the working directory of midp not the place from where I invoke it? or is there some other reason?

Nortona at 2007-7-12 17:48:57 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 3

i tried to redo your stuff (but i cannot find midp bin: i searched in WTK 2.2 and 2.5 and i didn't

find it !!) i try with the emulator bin and i've got an error with zayit bin...

for your problem, i think it is:

when you launch midp bin, he is trying to run the classes and searching the image in the

classes folder. he canno tfind it so that's why you've got an IOException.

have you tried to put the image in the classes folder?

suparenoa at 2007-7-12 17:48:57 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 4
you have to prepend the file name with a "/"so:ballSprite = new Sprite(Image.createImage("/pole.gif"));should work for you.
pandora_fooa at 2007-7-12 17:48:57 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 5
As I have said earlier, I have tried "/pole.gif" and it doesn't work.I am using the midp binary that comes with the midp distribution. When I am saying I try from command line it means, I am not using WTK or NetBeans. I am using the command line midp executable.
Nortona at 2007-7-12 17:48:57 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 6

the last thing that i could tell you is to use [url=http://antenna.sourceforge.net/]antenna [/url] to build your MIDlet (with [url=http://ant.sourceforge.net/]ant[/url] and the wtk libs)

[url=http://www.javaranch.com/newsletter/200403/Antenna.html]could help you[/url] for building app with antenna

suparenoa at 2007-7-12 17:48:57 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 7
I think you need to use res folder in classpath also
sailesh_dita at 2007-7-12 17:48:57 > top of Java-index,Java Mobility Forums,Java ME Technologies...
# 8

> As I have said earlier, I have tried "/pole.gif" and

> it doesn't work.

>

> I am using the midp binary that comes with the midp

> distribution. When I am saying I try from command

> line it means, I am not using WTK or NetBeans. I am

> using the command line midp executable.

i found this article :

http://developers.sun.com/techtopics/mobility/midp/articles/setup/

is it the tutorial used for your test?

suparenoa at 2007-7-12 17:48:57 > top of Java-index,Java Mobility Forums,Java ME Technologies...