Pradeep Simha
Pradeep Simha

Reputation: 18133

Eclipse plugin - file not found exception

In my plugin project, I added a new file called "database.properties", when I try to run the plugin I am getting below exception:

java.io.FileNotFoundException: database.properties (The system cannot find the file specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)

Here is my project structure:

enter image description here

Also I have included that file in build properties, screenshot is shown here:

enter image description here

I tried cleaning, restarting eclipse, building etc. But still system is unable to find the file. Can anyone help me? what I am missing here?

Upvotes: 1

Views: 967

Answers (1)

Serge Farny
Serge Farny

Reputation: 932

You have to access the file like that:

Bundle bundle = Platform.getBundle("your_plugn_id");
InputStream is = bundle.getEntry("database.properties").openStream();

And includeit in your build.properties:

bin.includes = META-INF/,\
           OSGI-INF/,\
           database.properties/,\
           .,\
           plugin.xml

Upvotes: 2

Related Questions