External jars in eclipse plug-in

后端 未结 6 1722
被撕碎了的回忆
被撕碎了的回忆 2021-02-04 15:08

I\'m creating an eclipse plug-in and I\'m having trouble with external jars. In my plug-in I start an application which requires some external jars. What do I have to do to expo

相关标签:
6条回答
  • 2021-02-04 15:44
    1. Open your plugin.xml
    2. Go to Runtime tab and add your JAR in the classpath section
    0 讨论(0)
  • 2021-02-04 15:45

    The approach from Andy Thomas mostly works, but you also need to export the packages needed by the existing plugin in the new wrapper plugin so that they can be accessed by the plugin at runtime.

    0 讨论(0)
  • 2021-02-04 15:55
    1. Copy the required external JAR files into a folder in your plug-in project; I like to call this folder lib, but whatever works for you.
    2. ..but as apposed to Zsolt Török (his solution did not work for me) I double-clicked on the plugin.xml, went to the build tab, at the bottom, I clicked Add JARs..., and hey presto, it showed my project, and I then navigated to lib and included the external jar, as per step 1.
    0 讨论(0)
  • 2021-02-04 15:58

    This is an easy way, though it does create an additional plug-in.

    In Eclipse:

    • Choose New>Other, then Plug-in Development>Plug-in from existing JAR archives.
    • Choose the jars you want to include.
    • On the next page, configure the plug-in.
    • In your plug-in's manifest, add the new plug-in as a dependency.
    • In your plug-in's Properties, add the new project under Java Build Path on the Projects tab.

    Edit: You may be able to combine the jars into your plug-in by instead combining both suggestions of Zsolt and user714965 below.

    0 讨论(0)
  • 2021-02-04 16:02

    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. The syntax is: 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.

    I have done this where the Jars are multi-purpose (such as apache-commons) on our file systems and again we control the environment.

    Reference the following: http://www.eclipsezone.com/eclipse/forums/t51870.html

    0 讨论(0)
  • 2021-02-04 16:05

    By following the steps below, the external JARs will be included when you export your plug-in:

    1. Copy the required external JAR files into a folder in your plug-in project; I like to call this folder lib, but whatever works for you.
    2. Open the 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.
    0 讨论(0)
提交回复
热议问题