Eclipse plugin with external third party jar

不想你离开。 提交于 2019-12-06 06:11:05

Ok I Solved my problem. The actual scenario was that I had a third part jar which was included in the wrapper plugin project and is required by other plugins to compile successfully. During the compilation (exporting the product) these other plugins uses the jar located in the wrapper plugin for successful compilation and for that I needed to provide the location of the jar under the java classpath of the wrapper plugin.

But once the the product is exported I didn't want this jar to be the part of the product, since its a third party jar and it should not be distributed with the exe. So the solution is

Under the wrapper plugin Manifest -> Runtime Tab -> Classpath provide the location of the jar. In my case it was

 src/main/resources/thridparty.jar 

Under the Build tab -> Binary Build select only manifest.

In the MANIFEST.MF include

Bundle-ClassPath: external:$thirdpartyjar_location$/thirdparty.jar,
src/main/resources/thirdparty.jar

Export the product and under the product configuration file add the system property

 -Dthirdpartyjar_location=path/to/the/thirdpartyjar

When you run the product using the exe it will use the jar from external path you provided in configuration.

Hope it will help someone.

Nick Wilson

Difficult problem to solve, but I think BJ Hargrave's answer here (https://stackoverflow.com/a/19552056/1257372) which suggest putting the jars on the classpath and getting the system bundle to export them is probably the best way.

You can configure the additional system bundle exports by adding a few lines to your application ini file:

org.osgi.framework.system.packages.extra= \
org.thirdparty.xxx; version=1.0

As an alternative the way we got round this was to wrap the application in an installer. The installation wizard displays the licence to the user and prompts them to download the third party libraries. The installer then adds them to the application. More work to set up, but makes the end users job easier.

In the manifest you need to import the external packages you are using:

Import-Package: org.thirdparty.xxx,org.thirdparty.yyy
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!