views:

968

answers:

2

I tried to add the apache vfs jar file as the runtime dependency. Even though it throws the below error:

java.lang.ClassNotFoundException: org.apache.commons.vfs.VFS at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:489) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:405) at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:393) at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319) at file_explorer.View.setInput(View.java:295) at file_explorer.View.initialize(View.java:130)

How can i resolve this, thanks in advance.

A: 

The best way to include external Jar in Eclipse RCP application is to package it as a plugin and then use classic plugin dependency.

Just create a new plugin containing only your Jar. Then in the build tab of the manifest editor, add your jar to the classpath (at the bottom right) and export all its packages in this same runtime tab. Also be sure to check that you jar is checked in the Build tab.

Nevertheless you should be able to use the jar in a Given plugin source code if you only add it to the classpath as I mentioned previously.

Because some other of your plugins may be interested in using the vfs jar and for separtion of concerns matter I think you should wrap it in its own plugin

Manuel Selva
+2  A: 

The easiest way is to find bundle in an existing OSGI bundle repository.

http://bundles.osgi.org/Main/Repository
http://www.springsource.com/repository/app/
http://www.eclipse.org/orbit/
http://www.knopflerfish.org/repo/index.html

springsource repo contains apache VFS bundle

Then you need to add the bundle to the target platform (or just copy it to the dropins folder)

ILX