Launching out of an Eclipse workspace is different that using a normal JAR 
in OSGi. When launching from an Eclipse workspace (-dev mode), the bin dir 
(output folder) is "placed" on the Bundle-Classpath automatically for you. 
So /bin/background.gif is found when looking for resource /background.gif. 
But when creating a JAR from your project and running in "normal" OSGI 
mode, then bin folder is not to be used. So background.gif would be in the 
root of the JAR.
-- 

BJ Hargrave
Senior Technical Staff Member, IBM
OSGi Fellow and CTO of the OSGi Alliance
[EMAIL PROTECTED]

office: +1 386 848 1781
mobile: +1 386 848 3788




From:
Xi Jiarong <[EMAIL PROTECTED]>
To:
[email protected]
Date:
2007-10-17 23:14
Subject:
[osgi-dev] help wanted about loading image files



Hi, everybody.
I am puzzled about how to build a *.jar bundle with some images located 
inside this *.jar bundle file.

Now, I am using as below:
public ImageIcon imagebg = new 
ImageIcon(getClass().getResource("background.gif"));
I put the image file background.gif in the class file folder 
/bin/background.gif, the same folder with other *.classs files.
and run this bundle via eclipse's Equinox, and can show the background 
image successfully.

But, if I export it as another single *.jar file, then run it in 
knopflerfish, then this jar file even can't be installed successfully in 
knopflerfis osgi framwork.
What's wrong with this?
How to solve this problem and let it run and show this image successfully 
in knopflerfish?

Thansk in advances! 
hope to get your help!

Best Regards!

----------------
Jerry_______________________________________________
OSGi Developer Mail List
[email protected]
http://www2.osgi.org/mailman/listinfo/osgi-dev
_______________________________________________
OSGi Developer Mail List
[email protected]
http://www2.osgi.org/mailman/listinfo/osgi-dev

Reply via email to