我在项目BuildPath中添加了myLibrary.jar并尝试从myLibrary.jar myClass调用静态方法,但有异常:
Caused by: java.lang.NoClassDefFoundError: application/Application
at rcp.handlers.RunGenerationHandler.execute(RunGenerationHandler.java:29)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
at org.eclipse.ui.internal.handlers.E4HandlerProxy.execute(E4HandlerProxy.java:90)
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)
... 38 more
Caused by: java.lang.ClassNotFoundException: application.Application cannot be found by rcp_1.0.0.qualifier
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:432)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:345)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:337)
at org.eclipse.osgi.internal.loader.ModuleClassLoader.loadClass(ModuleClassLoader.java:160)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 46 more
我确定该类存在于库中。 我尝试重建myLibrary.jar并再次添加项目,但问题仍然存在 下面是我尝试从我的类中调用静态方法的代码:
import application.Application;
...
if (generationString != null){
Application.main(generationString);
}
应用程序 - myLibrary.jar中的类
ldl = myLibrary
更新
我确实这么慢了=(
在附加在MANIFEST.MF中的RCP应用程序库中
例如:
Bundle-ClassPath: .,/directory/myLibrary.jar