Search code examples
javaeclipse-plugineclipse-rcpexecutable-jarrcp

Eclipse plugin with external third party jar


I have an RCP application which includes different plugins. In one of the plugin I am using an external third party jar. Due to copyrights reasons I cannot bundle that jar into my product. So I try to include the jar as external jar at runtime. what I have done is as follows

In the Plugin manifest.mf I have

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: EaCom-plugin;singleton:=true
Bundle-Version: 2.1.0
Require-Bundle: org.eclipse.core.runtime
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ClassPath: .,
 external:$eaapi_location$/eaapi.jar
Bundle-NativeCode: external:$eaapi_location$/SSJavaCOM.dll
Export-Package: org.sparx
Bundle-Vendor: %pluginVendor

Under Runtime -> Exported Packages I added

 org.sparx

Under the classpath I have

  external:$eaapi_location$/eaapi.jar

build.properties

source.. = src/main/java/,\
       src/main/scala/,\
       src/main/resources/,\
       src/test/java/,\
       src/test/scala/,\
       src/test/resources/
output.. = bin/
bin.includes = META-INF/,\

In the build.properties I have a warning on the very first line. The warning is

source.external:$eaapi_location$/eaapi.jar build entry is missing

I export the product: myrcpapp.exe and in the config file of my product myrcpapp.ini add vm arguments:-Deaapi_location=C:/JavaAPI

I get the following error

error message : java.lang.error: unresolved compilation problems: Repository cannot be resolved into a type

Though it works fine when I run in eclipse What I am missing ?

Any help will be highly appreciated.

Thanks


Solution

  • 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.