【问题标题】:URI scheme is not "file" plug in errorURI 方案不是“文件”插件错误
【发布时间】:2013-07-30 20:12:00
【问题描述】:

我收到了错误

URI 方案不是“文件”

在我运行我尝试创建的插件之后。错误是从以下方法抛出的:

protected File getFile(String fileName) throws URISyntaxException {
    System.out.println(fileName);

    URI binUri = EpsilonStandaloneExample.class.getResource(fileName).toURI();
    URI uri = null;
    System.out.println(uri);
    if (binUri.toString().indexOf("bin") > -1) {
        uri = new URI(binUri.toString().replaceAll("bin", "src"));
    }
    else {
        uri = binUri;
    }
    System.out.println(uri);
    return new File(uri);
}

当我将我的课程作为 java 应用程序运行时,一切正常,我得到了正确的路径:

file:/E:/epsilon-eclipse/workspace/Test2/src/org/eclipse/epsilon/examples/standalone/egl/oxfordDriver.egl

现在我正在实现一个插件并运行此代码,返回的 URI 是:

bundleresource://652.fwk1463565218/org/eclipse/epsilon/examples/standalone/egl/oxfordDriver.egl

此 URI 不正确,这就是引发错误的原因。

关于如何解决这个问题的任何建议?

【问题讨论】:

    标签: java file eclipse-plugin uri epsilon


    【解决方案1】:

    我假设您想加载一个文件,该文件是您插件中资源的一部分。使用文件路径是不可能的,因为插件中的所有资源都使用包相对 URL 解析(并且包本身可能部署为 jar 文件,因此甚至没有普通文件)。看看reading resources from a plugin

    还要确保您add those files to your build.properties(请参阅“二进制构建”部分)。将文件放在插件项目中是不够的。

    【讨论】:

      猜你喜欢
      • 2011-02-20
      • 2011-11-09
      • 1970-01-01
      • 2021-08-08
      • 2018-05-27
      • 1970-01-01
      • 2011-12-13
      • 2012-05-12
      • 1970-01-01
      相关资源
      最近更新 更多