I have common code between a Java application and an RCP application. So I have created an OSGI bundle which contains:
- a main class to use it as a classic jar
- an OSGi manifest to use it in my RCP application
I built all with Tycho Manifest-first and it worked fine until I needed to use an external jar in my common code.
I need to use jsch so I have add jsch in my MANIFEST.MF :
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Main-Class: mygroupid.Main
Bundle-Name: Common tools
Bundle-SymbolicName: common-tools
Bundle-Version: 1.0.1.qualifier
Export-Package: mygroupid,
mygroupid.tools
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.osgi.framework;version="1.3.0"
Require-Bundle: com.jcraft.jsch;bundle-version="0.1.46"
I build my RCP application with Tycho and it works. But when I run the bundle as pure JAR with java -jar myjar.jar
, I get the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: com/jcraft/jsch/JSchException
If I export my bundle with Eclipse, it works. So I have an error in my tycho configuration...
How to solve this problem ? Is there a jar-with-dependencies for Tycho ? It seems not to be the case What I have missed ?
(My configuration: Eclipse Juno with m2e, Tycho 0.16.0, p2: Juno, Tycho: packaging>eclipse-plugin, target-platform-configuration : resolver=p2 and pomDependencies=consider.)