Include resources into the JAR [message #23304] |
Wed, 26 November 2008 23:12 |
Eclipse User |
|
|
|
Originally posted by: news.s237965939.online.de
In my application there are images to display in forms. I can load them
from disk on the emulator. I've also imported the image in the elipse
project 'res' package/folder. But how will it go into the jar file and
how do I refer to it from the sourcecode? Currently I'm doing
Image image = Image.createImage( "/myPictue.jpg" );
picAlert.setImage(image);
TIA,
Hans
|
|
|
Re: Include resources into the JAR [message #23346 is a reply to message #23304] |
Thu, 27 November 2008 09:44 |
Eclipse User |
|
|
|
Originally posted by: news.s237965939.online.de
Ok folks, I found the answer myself. This works for me:
InputStream is = Object.class.getResourceAsStream("/mypic.jpg");
Image image = Image.createImage( is );
Thanks for reading,
Hans
|
|
|
|
Re: Include resources into the JAR [message #23558 is a reply to message #23473] |
Thu, 27 November 2008 17:41 |
Eclipse User |
|
|
|
Originally posted by: news.s237965939.online.de
Thanks David. As I wrote in my other post I've finally figured it out. Ended
up with simple two lines of code and the correct configuration.
THX,
Hans
"David Marques" <wtv368@motorola.com> wrote
> Hello Hans,
>
> The content in the source folders go into the JAR root, so for example if
> you put a 'myPictue.jpg' in the root of a source folder it will be on the
> JAR`s root and can be accessed with '/myPictue.jpg'. Just make sure your
> 'res' folder is a source folder and it should work fine.
>
> [],
>
> David Marques
>
|
|
|
Re: Include resources into the JAR [message #568716 is a reply to message #23304] |
Thu, 27 November 2008 09:44 |
Eclipse User |
|
|
|
Originally posted by: news.s237965939.online.de
Ok folks, I found the answer myself. This works for me:
InputStream is = Object.class.getResourceAsStream("/mypic.jpg");
Image image = Image.createImage( is );
Thanks for reading,
Hans
|
|
|
|
Re: Include resources into the JAR [message #568818 is a reply to message #23473] |
Thu, 27 November 2008 17:41 |
Eclipse User |
|
|
|
Originally posted by: news.s237965939.online.de
Thanks David. As I wrote in my other post I've finally figured it out. Ended
up with simple two lines of code and the correct configuration.
THX,
Hans
"David Marques" <wtv368@motorola.com> wrote
> Hello Hans,
>
> The content in the source folders go into the JAR root, so for example if
> you put a 'myPictue.jpg' in the root of a source folder it will be on the
> JAR`s root and can be accessed with '/myPictue.jpg'. Just make sure your
> 'res' folder is a source folder and it should work fine.
>
> [],
>
> David Marques
>
|
|
|
Powered by
FUDForum. Page generated in 0.05075 seconds