Packing Image Icons into jar

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Packing Image Icons into jar

Phase GmbH
Hi,

I have a number of Image Icons which are exposed in some Swing dialogs generated by plugins. I want to pack them into a common jar file, but the plugins fail to find them there.
What would be the right way to do that and where to place such jar file?

Regards
Christian Kreutzfeldt

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Packing Image Icons into jar

dscho
Hi Christian,

On Thu, 17 Jan 2013, Christian Kreutzfeldt wrote:

> I have a number of Image Icons which are exposed in some Swing dialogs
> generated by plugins. I want to pack them into a common jar file, but
> the plugins fail to find them there.
>
> What would be the right way to do that and where to place such jar file?

The common way is to refer to those files via URLs. Such URLs have the
form:

        jar:file:/path/to/my.jar!/resources/123.gif

and are typically retrieved by Java code like this:

        URL iconURL = getClass().getResource("/resources/123.gif");

The ImageIcon(URL) constructor comes in real handy with that strategy:

        http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/ImageIcon.html#ImageIcon%28java.net.URL%29

Ciao,
Johannes

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html