繁体   English   中英

随附3rd Jars

[英]Include 3rd party jars in bundle

我正在尝试将3rd party jar添加到我的捆绑包中。 我正在按照本教程http://www.aqute.biz/Blog/2007-02-19进行操作 ,但是在我的Activator中,当尝试从该外部jar引用一个类时遇到ClasNotFoundException。

我的捆绑罐目录结构:

-\MyBundle
  -\plugin.xml
  -\META-INF
    -\MANIFEST.MF
  -\org
    -\mybundle
      -\Activator.class
  -\3rdParty.jar

MANIFEST.MF看起来像这样:

...
Bundle-ClassPath: .,
 3rdParty.jar
...

它是Eclipse 3.5.1 RCP应用程序的一部分。

错误信息:

java.lang.ClassNotFoundException: 3rd.party.proxy.ConfiguratorProxy
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:494)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:410)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:398)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Unknown Source)
    at my.program.eclipse.core.ProcessEditorUploaderActivator.start(ProcessEditorUploaderActivator.java:111)

但是,当我调用this.getClass()。getResource(“ / 3rdParty.jar”)时,它可以工作。

编辑:问题已解决 我必须从我的RCP应用程序中删除org.eclipse.core.runtime,org.eclipse.equinox.app和org.eclipse.osgi目录。 有关包类路径的信息已缓存。

您是从Eclipse运行它吗? 如果是这样,您的第三方捆绑软件也应列在您的.classpath文件中。 您应该有这样的一行:

<classpathentry exported="true" kind="lib" path="lib/thirdparty.jar"/>

(使用MANIFEST编辑器时,这应该会自动发生)

如果要导出插件并以其他方式运行它,则需要一个build.properties文件,该文件应类似于:

source.. = src/ 
output.. = classes/ 
bin.includes = META-INF/,\
           .,\
           lib/thirdparty.jar

要检查的一些事情:

  • 您的3rdParty.jar确实在捆绑罐中吗? 用Winzip打开并检查。

  • 您的Manifest.MF是否正确? 尝试将Bundle-ClassPath:的所有条目放在一行上,没有新行:Bundle-ClassPath:。,3rdParty.jar

  • 您在哪里尝试访问课程? 从MyBundle.jar的类中可以看到内部jar的类,但是除非在清单中导出包,否则它们在框架中的其他捆绑包中将不可见。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM