Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 264
Markus Avatar asked May 08 '26 17:05

Markus


1 Answers

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
like image 178
Thomas Uhrig Avatar answered May 10 '26 07:05

Thomas Uhrig



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!