Problem reading resources from jar inside Idea.

We use Thread.currentThread().getContextClassLoader().getResourceAsStream(path) inside our jars to access resources.

This does not appear to work when the jar is inside an Idea plugin - it returns null.

Can you suggest a work around please.

MArkee

6 comments

Can't you use getClass().getClassLoader().getResourceAsStream(path)?

mark stephens wrote:

We use Thread.currentThread().getContextClassLoader().getResourceAsStream(path) inside our jars to access resources.

This does not appear to work when the jar is inside an Idea plugin - it returns null.

Can you suggest a work around please.

MArkee


--
Martin Fuhrer
Fuhrer Engineering AG
http://www.fuhrer.com

0

Its called statically. Any ideas?

0

It works with ClassName.class.getResourceAsStream()

Back in business :)

MArkee

0

I've the same problem. I have file-template, placed in jar (after compiling plugin). When installing this plugin in IDEA - it can't find this file inside my JAR, but it is really in it.

0

Yes, solution is using getResourceAsStream instread of getResource. getResourceAsStream - works well.

0

Please sign in to leave a comment.