有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

找不到java Eclipse插件文件异常

在我的插件项目中,我添加了一个名为“database.properties”的新文件,当我尝试运行插件时,我遇到以下异常:

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)

以下是我的项目结构:

enter image description here

我还将该文件包含在构建属性中,屏幕截图如下所示:

enter image description here

我尝试过清理、重新启动eclipse、构建等,但系统仍然无法找到该文件。有人能帮我吗?我错过了什么


共 (1) 个答案

  1. # 1 楼答案

    您必须这样访问文件:

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

    在你的身材中融入。属性:

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