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.
This is because you haven't added the SWT library to your buildpath. Follow the steps of the tutorial:
- 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.
- 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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With