Eclipse Plugin: java.lang.NoClassDefFoundError

As you can see:

enter image description here

I added jni4net.j-0.8.6.0.jar to my library links, but I get 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 run the project as an Eclipse-Application, it cannot find this class. The same code works in a regular Java project.

Does anyone know how to fix this?

+4
source share
4 answers

You need to add jar files to build.properties bin.includes file. In addition, in your MANIFEST.MF file, you must add them to the Runtime-> Classpath list (corresponding to the Bundle-ClassPath entry in MANIFEST.MF).

Edit: if you just put them in the referenced libraries, the OSGi system will not know about this fact.

+4
source

I had exactly the same problem with my .jar in the "Linked Libraries" folder (the jar was added through the right-click project β†’ Build path β†’ Configure build path β†’ Libraries β†’ Add external jar).

This is fixed: right-click project β†’ Build path β†’ Configure build path β†’ Order and export. Make sure your .jar file is checked. This adds it to the assembly class path. You might think that this will be automatically checked after the first addition of .jar using the above method, but it is not.

+5
source

This can also happen if your jar file depends on some other jar files for woking them, and you did not add them to your project.

+2
source

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

+1
source

Source: https://habr.com/ru/post/1495749/


All Articles