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

0
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

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
Avatar
Permanently deleted user

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

0
Avatar
Permanently deleted user

Thanks

0

请先登录再写评论。