Java 如何导入eclipse中尚未存在的类
我正在使用EclipseIDE-Android开发工具构建:v22.6.2-108550 我必须运行这个程序Java 如何导入eclipse中尚未存在的类,java,eclipse,Java,Eclipse,我正在使用EclipseIDE-Android开发工具构建:v22.6.2-108550 我必须运行这个程序 import org.eclipse.gef4.dot.DotExport; import org.eclipse.gef4.dot.DotImport; import org.eclipse.gef4.graph.Graph; import org.eclipse.gef4.zest.core.widgets.GraphWidget; import or
import org.eclipse.gef4.dot.DotExport;
import org.eclipse.gef4.dot.DotImport;
import org.eclipse.gef4.graph.Graph;
import org.eclipse.gef4.zest.core.widgets.GraphWidget;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class SampleUsage {
public static void main(String[] args) {
Shell shell = new Shell();
Graph graph = new DotImport(
"digraph{ "
+ "node[label=zested]; edge[style=dashed]; "
+ "1->2; 2->3; 2->4; 3->5; 4->6 "
+"}").newGraphInstance();
open(graph, shell);
System.out.println(new DotExport(graph).toDotString());
}
private static void open(Graph graph, final Shell shell) {
new GraphWidget(graph, shell, SWT.NONE);
shell.setText(Graph.class.getSimpleName());
shell.setLayout(new FillLayout());
shell.setSize(600, 300);
shell.open();
Display display = shell.getDisplay();
while (!shell.isDisposed())
if (!display.readAndDispatch())
display.sleep();
display.dispose();
}
}
但是公共类SampleUsage上面的所有导入命令都有错误,或者我们可以说,带有红色灯泡意味着这些包还没有出现。错误是import org.eclipse无法解决。如何将这些包导入IDE以运行此程序?如果您还可以告诉我这些包的位置,那就太好了。您可以通过右键单击Project->Build Path->Configure Build Path在eclipse中添加一个jar。在“库”选项卡下,单击“添加Jar”或“添加外部Jar”并给出Jar。好吧,看起来您必须通过选项2,但有时如果您必须导入现有项目,选项1将对您有所帮助 备选案文1: 在eclipse上导入现有项目:单击文件>导入并选择要导入的项目。如果eclipse显示错误,那么单击它并选择ImporttheProject选项manually。如果再次显示问题,请单击“项目>清理”来清理所有项目。 备选案文2: 在eclipse中添加jar。步骤:单击项目>构建路径>配置构建路径。然后单击AddJars并选择jar所在的位置。
谢谢 您必须告诉eclipse您必须从哪里添加这些类。您必须将包含这些类的JAR/库添加到项目的构建路径中。您可以通过右键单击项目->构建路径->配置构建路径在eclipse中添加JAR。在“库”选项卡下,单击“添加Jar”或“添加外部Jar”并给出Jar。@AnshuKunal您应该将其作为答案发布。