Markus
Markus

Reputation: 1482

Eclipse RCP: java.lang.ClassNotFoundException a runtime

One of my plugins uses a library (jar file).

  1. I created a folder called lib in my plugin and placed the jar file into it.
  2. I configured the build path by adding the jar file with "Add JARS..".
  3. I use the classes of the jar file in the plugin and it compiles fine.
  4. I start the RCP and get a ClassNotFoundException about the classes in the jar file.

What am I missing?

Upvotes: 3

Views: 2247

Answers (1)

Thomas Uhrig
Thomas Uhrig

Reputation: 31623

Welcome to the wonderful world of OSGi! :D

You have two options:

Repack the JAR as an OSGi bundle

You can go the OSGi way and repack your JAR in an OSGi bundle. This is clean and recommended in the sense of OSGi, since all code should be packaged in OSGi bundles (which in you case are called Eclipse plugins). However, this means additional work and I personally do not like it.

Use the bundle class path

Put the JAR file to the root (or a folder called lib) of your bundle and add a Bundle-ClassPath entry to your manifest:

Bundle-ClassPath: .,lib/library.jar

Upvotes: 9

Related Questions