Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » DSDP - Mobile Tools for Java (MTJ) » Include resources into the JAR
Include resources into the JAR [message #23304] Wed, 26 November 2008 23:12 Go to next message
Eclipse UserFriend
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 Go to previous messageGo to next message
Eclipse UserFriend
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 #23473 is a reply to message #23304] Thu, 27 November 2008 13:10 Go to previous messageGo to next message
David Marques is currently offline David MarquesFriend
Messages: 80
Registered: July 2009
Member
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 #23558 is a reply to message #23473] Thu, 27 November 2008 17:41 Go to previous message
Eclipse UserFriend
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 Go to previous message
Eclipse UserFriend
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 #568775 is a reply to message #23304] Thu, 27 November 2008 13:10 Go to previous message
David Marques is currently offline David MarquesFriend
Messages: 80
Registered: July 2009
Member
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 #568818 is a reply to message #23473] Thu, 27 November 2008 17:41 Go to previous message
Eclipse UserFriend
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
>
Previous Topic:Error reading a bean with an attribute "array of strings" from Axis WS
Next Topic:External JAR File
Goto Forum:
  


Current Time: Sat Dec 21 12:06:02 GMT 2024

Powered by FUDForum. Page generated in 0.05075 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top