[英]External jars in eclipse plug-in
I'm creating an eclipse plug-in and I'm having trouble with external jars. 我正在创建一个eclipse插件,我在使用外部jar时遇到了麻烦。 In my plug-in I start an application which requires some external jars.
在我的插件中,我启动了一个需要一些外部jar的应用程序。 What do I have to do to export them automatically with the rest of the plug-in?
如何使用插件的其余部分自动导出它们,我该怎么办?
Thanks in advance :) 提前致谢 :)
plugin.xml
plugin.xml
Runtime
tab and add your JAR in the classpath section Runtime
选项卡,然后在类路径部分中添加JAR By following the steps below, the external JARs will be included when you export your plug-in: 按照以下步骤,导出插件时将包含外部JAR:
lib
, but whatever works for you. lib
,但是对你有用。 build.properties
in your plug-in project and check the JARs you want to include in the build in the Binary Build section on the left. build.properties
,并在左侧的Binary Build部分中检查要包含在构建中的JAR。 This is an easy way, though it does create an additional plug-in. 这是一种简单的方法,但它确实创建了一个额外的插件。
In Eclipse: 在Eclipse中:
New>Other
, then Plug-in Development>Plug-in from existing JAR archives
. Plug-in Development>Plug-in from existing JAR archives
选择New>Other
,然后选择Plug-in Development>Plug-in from existing JAR archives
。 Java Build Path
on the Projects
tab. Projects
选项卡上的Java Build Path
下添加新项目。 Edit: You may be able to combine the jars into your plug-in by instead combining both suggestions of Zsolt and user714965 below. 编辑:您可以通过,而不是结合索尔特的两项建议及以下user714965到罐子合并到您的插件。
This is what has worked for me. 这对我有用。 If they are truly external, and this is a project for your company that is not going to be in the "wild" and you control the environment, and you have them out on the file system say at /opt/java/lib/somedir/some.jar you can tell the bundle where to find them by adding them to the Bundle-ClassPath entry in the MANIFEST.MF under META-INF.
如果它们真的是外部的,这是一个适合你的公司的项目,它不会处于“狂野”状态,你可以控制环境,你可以在文件系统上找到它们,请说/ opt / java / lib / somedir /some.jar你可以通过将它们添加到META-INF下的MANIFEST.MF中的Bundle-ClassPath条目来告诉bundle在哪里找到它们。 The syntax is: Bundle-ClassPath: ., external:/opt/java/lib/somedir/some.jar, external:/opt/java/lib/someotherdir/someother.jar
语法为:Bundle-ClassPath:。,external:/opt/java/lib/somedir/some.jar,external:/opt/java/lib/someotherdir/someother.jar
Also it would be prudent to use these in your build path so that you are working with the same jars in both build and runtime environments. 此外,在构建路径中使用这些是明智的,这样您就可以在构建和运行时环境中使用相同的jar。
I have done this where the Jars are multi-purpose (such as apache-commons) on our file systems and again we control the environment. 我已经完成了这个,在我们的文件系统上Jars是多用途的(例如apache-commons),我们再一次控制环境。
Reference the following: http://www.eclipsezone.com/eclipse/forums/t51870.html 参考以下内容: http : //www.eclipsezone.com/eclipse/forums/t51870.html
Andy Thomas的方法大多有效,但您还需要在新的包装器插件中导出现有插件所需的包,以便插件在运行时可以访问它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.