How to access properties file needed in plugin?


I have a plugin with some kind of errors view (it's a tree).
Each node in the tree stores it's own error code (error type).
I need to open help with the proper error description (depending on what was selected in the tree).

To open it I have some kind of the property file.
Here is it's format:
ERROR.CODE1 = topic1
ERROR.CODE2 = topic2
(where topic is topic name to open in the help).

Now I have a problem where to store this file to and how to read it from there.
I wanted to store it in the plugin folder, but I failed to find it in the plugin code.
I tried to use ApplicationManager.getApplication().getPlugin("").getPath();

But, it couldn't be compiled with jars from 5.x IDEA (and I need to support not only 6.0 but 5.x versions too). But compilation failed. It works only on 6.0 IDEA.

Could you please explain where to store such types of files and how to get access to them?


Comment actions Permalink

I am very sorry, but why nobody answer the question?
I thought me as a begginner don't know the answer but all of the good plugin developers should know it,,
Please, don't ignore my question if you know the answer.

Comment actions Permalink

Hi Maria,

It's Christmas, so most probably not everybody is in front of the screen all day... ;)

Back to your question:
Just do it like anybody else, put your resource file somewhere in your source tree and access it with ResourceBundle.getBundle(...). So if your resources are located in com/yurchenko/whatever/, you should call ResourceBundle.getBundle("com.yurchenko.whatever.Plugin") to load them.

Comment actions Permalink

Thank you, Martin.
It worked for me.

Also I found a solution how to get plugin directory (for the future, if I need it).


Please sign in to leave a comment.