Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将外部jar添加到EclipseRCP应用程序?_Eclipse_Eclipse Rcp - Fatal编程技术网

如何将外部jar添加到EclipseRCP应用程序?

如何将外部jar添加到EclipseRCP应用程序?,eclipse,eclipse-rcp,Eclipse,Eclipse Rcp,我尝试添加apachevfsjar文件作为运行时依赖项。即使它抛出以下错误: java.lang.ClassNotFoundException:org.apache.commons.vfs.vfs 位于org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:489) 位于org.eclipse.osgi.internal.loader.BundleLoader.findClass(Bund

我尝试添加apachevfsjar文件作为运行时依赖项。即使它抛出以下错误:

java.lang.ClassNotFoundException:org.apache.commons.vfs.vfs 位于org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:489) 位于org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:405) 位于org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:393) 位于org.eclipse.osgi.internal.baseAdapter.DefaultClassLoader.loadClass(DefaultClassLoader.java:105) 位于java.lang.ClassLoader.loadClass(ClassLoader.java:251) 位于java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) 在文件_explorer.View.setInput(View.java:295)中 在文件_explorer.View.initialize(View.java:130)中


如何解决这个问题,请提前感谢。

在Eclipse RCP应用程序中包含外部Jar的最佳方法是将其打包为插件,然后使用经典的插件依赖关系

只需创建一个只包含Jar的新插件。然后在清单编辑器的build选项卡中,将您的jar添加到类路径(在右下角),并在同一个运行时选项卡中导出其所有包。还要确保在Build选项卡中检查了jar

尽管如此,如果您只将jar添加到我前面提到的类路径中,那么您应该能够在给定的插件源代码中使用jar


因为您的其他一些插件可能对使用vfs jar感兴趣,并且对于问题的分离,我认为您应该将其封装在自己的插件中

最简单的方法是在现有的OSGI捆绑包存储库中查找捆绑包

http://bundles.osgi.org/Main/Repository
http://www.springsource.com/repository/app/
http://www.eclipse.org/orbit/
http://www.knopflerfish.org/repo/index.html
springsourcerepo包含apachevfs包

然后,您需要将捆绑包添加到目标平台(或者只是将其复制到dropins文件夹)


为了正确地将捆绑包安装到较新版本的eclipse中,您应该使用现有的p2存储库,并将捆绑包从p2存储库安装到您的运行时平台中。有两种方法:您可以使用现有的方法(如orbit p2 repo),或者,如果要将所需的JAR添加到项目类路径中,可以使用p2 publisher创建自己的JAR。将所需文件添加到项目结构中的lib目录中。然后从项目中单击plugin.xml的“运行时”选项卡,并将所需JAR从lib目录添加到项目中类路径。

EclipseRCP是一个OSGi环境,它扩展了Java依赖关系模型,因此您不能简单地获取一个
jar
文件并希望它能工作。要使用外部jar,您必须首先将其构建为插件,这会有所帮助,您可以按照自述文件进行操作

插件就绪后,您应该安装插件并将其添加到
MANIFEST.MF
。然后重新启动Eclipse以使插件工作

更简单的方法是,您无需安装插件,只需遵循以下步骤(但构建jar):

  • 转到
    plugin.xml
    ->
    运行时
    选项卡
  • 单击
    classpath
    部分的
    Add
    ,然后将插件添加到classpath
  • 确保文本区域中有
    路径,否则
    新建
    路径