在接口内运行java类
您好,我正在处理一个eclipse RCP项目,我需要从我的ViewPart中的一个类运行一个函数,通过将实例添加到按钮选择的侦听器,我正在函数中使用Gate NLP,因此在运行该项目后,我会遇到很多异常,这是其中的一部分:在接口内运行java类,java,eclipse,gate,Java,Eclipse,Gate,您好,我正在处理一个eclipse RCP项目,我需要从我的ViewPart中的一个类运行一个函数,通过将实例添加到按钮选择的侦听器,我正在函数中使用Gate NLP,因此在运行该项目后,我会遇到很多异常,这是其中的一部分: org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: gate/util/GateException at org.eclipse.e4.core.internal.di
org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError: gate/util/GateException
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:63)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:877)
at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:857)
at org.eclipse.e4.core.internal.di.InjectorImpl.inject(InjectorImpl.java:119)
at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:333)
at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:254)
at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:162)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:102)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:71)
at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:53)
at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:129)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:949)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:633)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$6.run(PartRenderingEngine.java:526)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
....
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: java.lang.NoClassDefFoundError: gate/util/GateException
at segmentation.View.createPartControl(View.java:258)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:142)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityView.createPartControl(CompatibilityView.java:174)
at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:323)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
... 84 more
Caused by: java.lang.ClassNotFoundException: gate.util.GateException cannot be found by Segmentation_1.0.0.qualifier
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(ClassLoader.java:358)
... 93 more
这就是我如何使用这门课:
btnSegmenter.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
SegClass s = new SegClass();
if ((!(text_2.getText().isEmpty())) && (!(text_1.getText().isEmpty())))
{
try {
s.Segmenter(text_3.getText(), text_2.getText());
} catch (GateException | IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
}
});
所以请帮我找到另一种方式来管理我的班级谢谢 您是否在插件运行时添加了与“分段”相关的jar或文件。
Plugin.xml->Run time->class path->add->看一看
NoClassDefFoundError
总是关于编译时存在但在运行时丢失的类。什么意思是编译时存在但在运行时丢失?实际上,我在一个简单的java项目上测试了代码,然后我创建了一个类的实例,并在按下按钮后尝试在那里运行。您能告诉我问题出在哪里吗?类加载器在运行时找不到包含该类的JAR或目录。换句话说,确保gate.util.GateException
在类路径上。打开你的plugin.xml文件plugin.xml->运行时->类路径->添加->我发现这非常有用,谢谢你的帮助,每个人都使用Import>文件系统将jar文件导入插件项目,比如在/lib目录中。使用“添加…”将JAR添加到plugin.xml>Runtime选项卡的classpath部分。使用“新建…”添加“.”库返回(当然没有引号)。确保二进制构建在plugin.xml>build选项卡上导出新的jar文件。保存项目时,使用上下文菜单>PDE工具>更新类路径将JAR正确添加到eclipse项目类路径。我用过这个,但我有一个问题,我是否必须添加新的…“添加”。“每个罐子的库返回??