relative path in jar file

Hi there.
I have created a plugin and placed the content in a jar file.
The structure is like this:

com/intellij/openapi/modification/ META-INF/plugin.xml resources/icons/]]>

My question is how do i get the icons image files using the relative path. I have tried loading them using the path "resources/icons/icon.png" but it doen't work.
I know this is more a Java question but can anybody give me a hint? For what i have found so far i think i should use the ClassLoaded.getResource() method but i still can't make it work.

Raul

3 comments

.getClass().getResource("/resources/icons/") or .class.getResource("/resources/icons/]]>")

0

Chris Sherratt wrote:

<this>.getClass().getResource("/resources/icons/<*.png>")


That isn't cool, a subclass might have been loaded with a different
classloader.

or

<clazz>.class.getResource("/resources/icons/<*.png>")


This is better.

0

Thanks guys.
I tried both of them and they work.
Can you just explain why is the second one better?

0

Please sign in to leave a comment.