JasonS JasonS - 8 days ago 8
Java Question

How to add 3rd party libraries into Eclipse RCP?

I'm using Eclipse RCP to write a GUI which would use Spring framework related projects, such as:


  • Spring WebSocket client

  • Spring Web Client



So my question is how to add this dependencies elegantly? (Spring does not support osgi for a long time, there are many other ways which are very complicated and tedious)

Answer

I've found a good Solution to solve this problem. It will use following skills: Maven, Eclipse Plugin

The steps are:

  • first, write the pom.xml which contains the dependencies you want, for example: spring-websocket

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-websocket</artifactId>
    </dependency>
    
  • then, you need to download all websocket jars, you need to use maven command to help you to do that :), the jars are all in /target folder by default

    mvn dependency:copy-dependencies

    Note: maven will handle the dependency tree.

  • next, in Eclipse create a "Plug-in from Existing JAR Archives" project and import these jars

    Note: Un-check the "Upzip the JAR archives into the project". (Or all jars will be decompressed into folder and files then stored in the project)

  • finally, add this plugin project in your main RCP project as a dependency. And you can write/run your websocket client now!

Hope this is an elegant way to solve this problem.

Comments