org.eclipse.swt.*; The import org.eclipse cannot be resolved
Asked Answered
A

4

22

I am trying to write a small program that requires the import statement import org.eclipse.swt.*;. (I'm practicing with THIS tutorial).

However, Eclipse won't compile the program and is giving me the error "The import org.eclipse cannot be resolved"

Google hasn't been such a a great friend at finding the answer this time.

Aquitaine answered 8/5, 2013 at 13:41 Comment(0)
J
36

This is because you haven't added the SWT library to your buildpath. Follow the steps of the tutorial:

  1. 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.php Look for the section titled SWT Binary and Source.
  2. From main menu tool bar, select "File" followed by "Import". Doing so will bring up the "Import wizard" dialog.
  3. Now select "Existing Projects into Workspace" and click on "Next" button.
  4. Click on "Select archive file" followed by "Browse" button. Now locate the SWT archive that you downloaded in step 1.
  5. Click the Finish button to finish importing the SWT project into your workspace.
  6. Create new java project from File > New Java Project.
  7. Right-click on the project and select the Properties command to open the Properties dialog.
  8. Select the Java Build Path followed by Projects tab and click the Add button.
  9. Select the org.eclipse.swt project and click OK to finish adding the SWT libraries to your project's classpath
Jeffery answered 8/5, 2013 at 13:46 Comment(2)
I took all these steps. I no longer get the error, but the program doesn't run because: Can't load IA 32-bit .dll on a AMD 64-bit platform. Do you know if there's any way around this?Aquitaine
@Imray: Maybe you have downloaded the wrong SWT version. 32bit where you should have 64bit. There are several question about this error on stackoverflow also...Jeffery
H
8

Create a Maven project and add org.eclipse.swt dependency in 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>
Hardan answered 17/9, 2016 at 13:50 Comment(0)
M
3

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

Mauldin answered 28/9, 2013 at 21:31 Comment(0)
C
1

I had the same issue, was using wrong settings in the target file. If you are working with a target-definition make sure to use the right platform/architecture settings, see

enter image description here

Crist answered 30/9, 2022 at 13:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.