java.lang.NoClassDefFoundError:org/eclipse/draw2d/LightweightSystem
我正在使用Eclipse图形编辑框架()构建一个Eclipse插件项目。 我可以编写一个类,用我在互联网上找到的示例代码进行测试,代码如下:java.lang.NoClassDefFoundError:org/eclipse/draw2d/LightweightSystem,java,eclipse,eclipse-plugin,eclipse-rcp,draw2d,Java,Eclipse,Eclipse Plugin,Eclipse Rcp,Draw2d,我正在使用Eclipse图形编辑框架()构建一个Eclipse插件项目。 我可以编写一个类,用我在互联网上找到的示例代码进行测试,代码如下: public class Test { public static void main(String args[]){ Shell shell = new Shell(); shell.open(); Display display = shell.getDisplay(); Lig
public class Test {
public static void main(String args[]){
Shell shell = new Shell();
shell.open();
Display display = shell.getDisplay();
LightweightSystem lws = new LightweightSystem(shell);
IFigure panel = new Figure();
lws.setContents(panel);
RectangleFigure node1 = new RectangleFigure();
RectangleFigure node2 = new RectangleFigure();
node1.setBackgroundColor(ColorConstants.red);
node1.setBounds(new Rectangle(30, 30, 64, 36));
node2.setBackgroundColor(ColorConstants.blue);
node2.setBounds(new Rectangle(300, 300, 64, 36));
PolylineConnection conn = new PolylineConnection();
conn.setSourceAnchor(new ChopboxAnchor(node1));
conn.setTargetAnchor(new ChopboxAnchor(node2));
conn.setTargetDecoration(new PolygonDecoration());
Label label = new Label("Midpoint");
label.setOpaque(true);
label.setBackgroundColor(ColorConstants.buttonLightest);
label.setBorder(new LineBorder());
conn.add(label, new MidpointLocator(conn, 0));
panel.add(node1);
panel.add(node2);
panel.add(conn);
while (!shell.isDisposed ()) {
if (!display.readAndDispatch ())
display.sleep ();
}
}//main
}
它起作用了
但是-当我尝试在EditorPart(org.eclipse.ui.IEditorPart
)实例类中构建图形时,它会变糟,并给出以下错误代码:
**org.eclipse.e4.core.di.InjectionException: java.lang.NoClassDefFoundError:** org/eclipse/draw2d/LightweightSystem
这很奇怪,因为我在编辑器的createPartControl
方法中只写了3行:
Shell shell = parent.getShell();
Display display = shell.getDisplay();
LightweightSystem lws = new LightweightSystem(shell);
那么有什么身体帮助吗?您的依赖项设置正确吗?您需要为
LightweightSystem
Tks添加org.eclipse.draw2d,这是由目标平台引起的。转到运行配置>插件>目标平台,添加org.eclipse.draw2d