org.eclipse.swt.*; 导入 org.eclipse 无法解析
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16442294/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
org.eclipse.swt.*; The import org.eclipse cannot be resolved
提问by CodyBugstein
I am trying to write a small program that requires the import statement import org.eclipse.swt.*;
. (I'm practicing with THIStutorial).
我正在尝试编写一个需要 import 语句的小程序import org.eclipse.swt.*;
。(我正在练习本教程)。
However, Eclipse won't compile the program and is giving me the error "The import org.eclipse cannot be resolved
"
但是,Eclipse 不会编译程序并给我错误“ The import org.eclipse cannot be resolved
”
Google hasn't been such a a great friend at finding the answer this time.
谷歌这次在寻找答案方面并不是一个好朋友。
回答by Kai
This is because you haven't added the SWT library to your buildpath. Follow the steps of the tutorial:
这是因为您尚未将 SWT 库添加到您的构建路径中。按照教程的步骤操作:
- Download SWT library. For 3.1.2 version of eclipse, SWT library is available at http://archive.eclipse.org/eclipse/downloads/drops/R-3.1.2-200601181600/index.phpLook for the section titled SWT Binary and Source.
- From main menu tool bar, select "File" followed by "Import". Doing so will bring up the "Import wizard" dialog.
- Now select "Existing Projects into Workspace" and click on "Next" button.
- Click on "Select archive file" followed by "Browse" button. Now locate the SWT archive that you downloaded in step 1.
- Click the Finish button to finish importing the SWT project into your workspace.
- Create new java project from File > New Java Project.
- Right-click on the project and select the Properties command to open the Properties dialog.
- Select the Java Build Path followed by Projects tab and click the Add button.
- Select the org.eclipse.swt project and click OK to finish adding the SWT libraries to your project's classpath
- 下载 SWT 库。对于 3.1.2 版本的 eclipse,SWT 库位于 http://archive.eclipse.org/eclipse/downloads/drops/R-3.1.2-200601181600/index.php查找标题为 SWT Binary and Source 的部分。
- 从主菜单工具栏中,选择“文件”,然后选择“导入”。这样做将打开“导入向导”对话框。
- 现在选择“Existing Projects into Workspace”并点击“Next”按钮。
- 单击“选择存档文件”,然后单击“浏览”按钮。现在找到您在步骤 1 中下载的 SWT 档案。
- 单击 Finish 按钮完成将 SWT 项目导入到您的工作区的过程。
- 从文件 > 新建 Java 项目创建新的 Java 项目。
- 右键单击项目并选择“属性”命令以打开“属性”对话框。
- 选择 Java Build Path,然后选择 Projects 选项卡,然后单击 Add 按钮。
- 选择 org.eclipse.swt 项目并单击 OK 完成将 SWT 库添加到项目的类路径
回答by user6842896
Create a Maven project and add org.eclipse.swt
dependency in pom.xml
:
创建一个 Maven 项目并在 中添加org.eclipse.swt
依赖项pom.xml
:
<!-- https://mvnrepository.com/artifact/org.eclipse.swt.org.eclipse.swt.win32.win32.x86_64.4.3.swt/org.eclipse.swt.win32.win32.x86_64 -->
<dependency>
<groupId>org.eclipse.swt.org.eclipse.swt.win32.win32.x86_64.4.3.swt</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>
<version>4.3</version>
</dependency>
回答by Mayaul Kayiim
You can find the 64bit version of the SWT library by changing the download url to this: http://www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops4/R-4.3-201306052000/swt-4.3-win32-win32-x86_64.zip
您可以通过将下载 url 更改为以下内容来找到 64 位版本的 SWT 库:http: //www.eclipse.org/downloads/download.php?file=/eclipse/downloads/drops4/R-4.3-201306052000/swt -4.3-win32-win32-x86_64.zip