> InputStream is = getClass().getResourceAsStream("/test.png");
> image = Image.createImage (is);
what does your jar directory look like?

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Jeff - 15 Oct 2005 08:35 GMT
What do you mean with a jar directory?
I created this midlet with KToolbar and KToolbar created a directory (on my
hard drive c:\WTK22\... ) for this midlet, but it didn't create a sub-folder
named "jar".... (but it created many other sub-folders : "bin", "classes",
"lib", "res", "src", "tmpclasses", "tmplib")
I've just placed the image in the "res" sub folder and then created the
package. I mean I did choose " Project | Package | Create Package" in
KToolbar, I didn't do anything else for getting the image into the package
Jeff
>> InputStream is = getClass().getResourceAsStream("/test.png");
>> image = Image.createImage (is);
>
> what does your jar directory look like?
Roedy Green - 15 Oct 2005 09:00 GMT
>I've just placed the image in the "res" sub folder and then created the
>package. I mean I did choose " Project | Package | Create Package" in
>KToolbar, I didn't do anything else for getting the image into the package
In that case, lets find out what your classpath is. Dump it out the
system property.
System.out.println( System.getProperty( "java.class.path" ) );
Your resource had better be DIRECTLY in one on the classpath elements,
not buried in a subdir of it.
If you changed that to
InputStream is = getClass().getResourceAsStream("test.png");
Then you should have a file called com/yourdomain/test/test.png in
one of the classpath elements.
where the package for test is com.yourdomain.test

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.
Jeff - 15 Oct 2005 09:35 GMT
When I run this code in the emulator:
System.out.println( System.getProperty( "java.class.path" ) );
it returns "null" (I run with the text "java.class.path" as argument)
When running the code on my emulator everything works fine, it shows the
image in the window... everything is okay when runnning from the emulator,
it's when I run this midlet on the mobile I get trouble with this image...
maybe it's because the midlet is unable to find the image in the package
when installed on the mobile...??
>>I've just placed the image in the "res" sub folder and then created the
>>package. I mean I did choose " Project | Package | Create Package" in
[quoted text clipped - 16 lines]
>
> where the package for test is com.yourdomain.test
Andrew Thompson - 15 Oct 2005 11:06 GMT
> When I run this code in the emulator:
>
[quoted text clipped - 5 lines]
> image in the window... everything is okay when runnning from the emulator,
> it's when I run this midlet on the mobile I get trouble ..
I suspect this 'trouble' is security related.
An untrusted *Applet* will not show you the java.class.path
(unless it is run in the *MSVM* - which will tell you directly
where the core java classes are stored, no problem)
Darryl L. Pierce - 15 Oct 2005 14:35 GMT
> System.out.println( System.getProperty( "java.class.path" ) );
That's an undefined property in the MIDP.

Signature
Darryl L. Pierce <mcpierce@gmail.com>
Homepage: http://mcpierce.multiply.com/
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant
> When I run the code below on the emulator, the image is shown and everything
> seems to be working... but it doesn't work on my mobile (nokia 6630).... I'm
> not sure why but it looks like this test method don't return....
Check that your JAR file has the image in it.
> Image image;
> try
[quoted text clipped - 7 lines]
> }
> }
If you're loading the image from the JAR file, rather than from some
other source that only returns a stream, then you should just use:
Image image = Image.createImage("/test.png");

Signature
Darryl L. Pierce <mcpierce@gmail.com>
Homepage: http://mcpierce.multiply.com/
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant
Jeff - 15 Oct 2005 15:40 GMT
I replaced this code:
InputStream is = getClass().getResourceAsStream("/test.png");
image = Image.createImage (is);
with this code
Image image = Image.createImage("/test.PNG");
And now it works on both emulator and mobile phone
I'm very thankful for all the help you guys have given me on this subject.
>> When I run the code below on the emulator, the image is shown and
>> everything seems to be working... but it doesn't work on my mobile (nokia
[quoted text clipped - 20 lines]
>
> Image image = Image.createImage("/test.png");
Darryl L. Pierce - 15 Oct 2005 16:09 GMT
> I replaced this code:
> InputStream is = getClass().getResourceAsStream("/test.png");
[quoted text clipped - 6 lines]
>
> I'm very thankful for all the help you guys have given me on this subject.
You're welcome, mate. :)

Signature
Darryl L. Pierce <mcpierce@gmail.com>
Homepage: http://mcpierce.multiply.com/
"Bury me next to my wife. Nothing too fancy..." - Ulysses S. Grant