Stefan Falk
Stefan Falk

Reputation: 25367

Eclipse plugin: java.lang.NoClassDefFoundError

As you can see:

enter image description here

I added jni4net.j-0.8.6.0.jar to my referenced libraries but I still receive a java.lang.NoClassDefFoundError Exception:

java.lang.NoClassDefFoundError: net/sf/jni4net/Bridge
    at sibeclipseplugin.debug.DebuggerInterface.initialize(DebuggerInterface.java:15)
    at sibeclipseplugin.debug.SibDebugTarget.<init>(SibDebugTarget.java:65)
    at sibeclipseplugin.ui.launch.LaunchConfigurationDelegate.launch(LaunchConfigurationDelegate.java:30)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:858)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:707)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1018)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1222)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:53)
Caused by: java.lang.ClassNotFoundException: net.sf.jni4net.Bridge cannot be found by SIBEclipsePlugin_0.0.0.1
    at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:501)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:421)
    at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:412)
    at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:107)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    ... 8 more

I have no idea what the problem is. When I start the project as Eclipse-Application it can't find that class. Running the same code in a normal Java-Project works.

Does anybody know how to fix this?

Upvotes: 7

Views: 16850

Answers (4)

Amir
Amir

Reputation: 2415

It is not marked to export in the project properties: "Project Properties" > "Order and Export" tab > make sure the .jar file is checked for export.

Upvotes: 2

Steve B
Steve B

Reputation: 1246

I had exactly the same issue with my .jar in my Referenced Libraries folder (jar was added via right click project --> Build Path --> Configure Build Path --> Libraries --> Add External Jar).

This fixed it: right click project --> Build Path --> Configure Build Path --> Order and Export. Make sure your .jar file is checked. This adds it to the build class path. You'd think this would be automatically checked after first adding the .jar via the above method but it wasn't.

Upvotes: 6

Abhishek Singh
Abhishek Singh

Reputation: 9729

This may also happen if your jar file is dependent on some other jar files for their woking and you have not added them in your project.

Upvotes: 3

Tassos Bassoukos
Tassos Bassoukos

Reputation: 16142

You need to add the jar files in your build.properties bin.includes entry. Also, in your MANIFEST.MF file, they need to be added in the Runtime->Classpath list (corresponds to the Bundle-ClassPath entry in the MANIFEST.MF).

Edit: if you just put them in the referenced libraries, the OSGi system will not be aware of that fact.

Upvotes: 8

Related Questions