I'm adding a jar (org.json.simple) to a plugin.
I've looked around for how to do so and everything I see says "Right-click project -> Build Path -> configure -> libraries -> Add External Jar". I even tried "Add Jar" and had the jar in either the root of the project and a lib(s) folder (plugin/jar or plugin/lib/jar). This is not working. When launching the app from eclipse, I keep getting the same error (NoClassDefFoundError). This error occurs if I launch the exported app as well plus splash image doesn't show (separate issue). My current solution is creating a plugin from the jar source and adding that to my feature.
!SESSION 2024-09-01 13:58:16.796 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.8.0_421
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments: -product tcmagic.ui.product -clearPersistedState
Command-line arguments: -product tcmagic.ui.product -data C:\Users\Danny\Downloads\EclipseRcpPluginDev\Neon3\workspace11/../runtime-tcmagic.product -dev file:C:/Users/Danny/Downloads/EclipseRcpPluginDev/Neon3/workspace11/.metadata/.plugins/org.eclipse.pde.core/tcmagic.product/dev.properties -os win32 -ws win32 -arch x86_64 -consoleLog -clearPersistedState -data @noDefault
!ENTRY org.eclipse.osgi 4 0 2024-09-01 13:58:20.829
!MESSAGE Application error
!STACK 1
org.eclipse.e4.core.di.InjectionException: org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:65)
at org.eclipse.e4.core.internal.di.InjectorImpl.invokeUsingClass(InjectorImpl.java:282)
at org.eclipse.e4.core.internal.di.InjectorImpl.invoke(InjectorImpl.java:259)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.invoke(ContextInjectionFactory.java:107)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.lambda$0(E4Application.java:238)
at java.util.Optional.ifPresent(Unknown Source)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.createE4Workbench(E4Application.java:234)
at org.eclipse.e4.ui.internal.workbench.swt.E4Application.start(E4Application.java:148)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
Caused by: org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException)
at org.eclipse.swt.SWT.error(SWT.java:4533)
at org.eclipse.swt.SWT.error(SWT.java:4448)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:185)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4211)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3827)
at tcmagic.ui.Splash.prompt(Splash.java:119)
at tcmagic.ui.LifeCycle.postContextCreate(LifeCycle.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:55)
... 20 more
Caused by: java.lang.NoClassDefFoundError: org/json/simple/parser/ParseException
at tcmagic.db.mtgjson.Mtgjson.getSetListFile(Mtgjson.java:102)
at tcmagic.db.mtgjson.Mtgjson.getSetLists(Mtgjson.java:110)
at tcmagic.db.Database.createCards(Database.java:41)
at tcmagic.ui.Splash.run(Splash.java:51)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:182)
... 29 more
Caused by: java.lang.ClassNotFoundException: org.json.simple.parser.ParseException cannot be found by tcmagic.db_1.0.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:461)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:372)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:364)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:161)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 35 more
An error has occurred. See the log file
C:\Users\Danny\Downloads\EclipseRcpPluginDev\Neon3\workspace11\.metadata\.plugins\org.eclipse.pde.core\tcmagic.product\1725217097207.log.
How do I add a jar to a plugin classpath?
Dependencies for plug-ins are managed entirely by the MANIFEST.MF
file at runtime. Tinkering with the Java Build Path directly only affects compile-time. Open the MANIFEST.MF
in its proper editor and you'll be able to add the jar there.