SWT, the Standard Widget Toolkit, will help us to draw windows for the Java platform.
On this webpage you will find links to download last stable releases http://www.eclipse.org/swt/
Once downloaded, open Eclipse, right click on the Explorer tab, then : Import... > General > Existing Projects into Workspace.
Click Next then select the Select archive file option and browse until, for example for Windows OS, your swt-3.7.1-win32-win32-x86.zip file.
Click Finish.
Now in your Package Explorer you can see the org.eclipse.swt project.
Right click in this Explorer to create a new Java project named for example project1.
Right click on project1 > Build Path > Configure Build Path > Java Build Path.
On the right there are several tabs.
Select Projects and click Add...
Select org.eclipse.swt and click OK.
You project project1 is now linked with SWT and you can use its classes.
Comments
TheCric (not verified)
Tuesday, December 6, 2011 - 3:56am
Permalink
Thank You Mi-K !!!
Thank You Mi-K !!!
HelloWorldSWT which is the 1st example of SWT given after the installation of Eclipse does not work on Windows (I just tested it on Seven).
Yypically you get those errors:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-win32-3738 in java.library.path
no swt-win32 in java.library.path
Can't load library: C:\Users\<YourUserName>\.swt\lib\win32\x86\swt-win32-3738.dll
Can't load library: C:\Users\<YourUserName>\.swt\lib\win32\x86\swt-win32.dll
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:285)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:194)
at org.eclipse.swt.internal.C.<clinit>(C.java:21)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:138)
at HelloWorldSWT.main(HelloWorldSWT.java:13)
After the download of swt-3.7.1-win32-win32-x86.zip and by following the above given explanations by Mi-K, it just works.
By the way you can find swt-3.7.1-win32-win32-x86.zip for example here:
http://eclipse.ialto.com/eclipse/downloads/drops/R-3.7.1-201109091335/
Summer (not verified)
Wednesday, December 7, 2011 - 3:14am
Permalink
Yes, this fix worked for me
Yes, this fix worked for me as well. Thanks for that!
The Dafty Sage (not verified)
Monday, January 23, 2012 - 9:27pm
Permalink
They should add this step to
They should add this step to the tutorial :-D
Meg (not verified)
Wednesday, February 8, 2012 - 7:44pm
Permalink
Yes this does work - in my
Yes this does work - in my eclipse you have to right click on your project and select "Properties" and then navigate to the build path screen.
Thank you!
Mario (not verified)
Saturday, March 10, 2012 - 12:59pm
Permalink
Thank you so much, these
Thank you so much, these steps fix my problem.
Kostyanus (not verified)
Wednesday, August 6, 2014 - 3:04pm
Permalink
Hi, it does not works now.
Hi, it does not works now.
Eclipse says "Some projects cannot be imported because they already exist in the workspace". Please, help!
Mi-K
Wednesday, August 6, 2014 - 6:49pm
Permalink
Hello Kostyanus,
Hello Kostyanus,
Just rename your project with another name or delete it from your computer.
kostyanius (not verified)
Wednesday, August 6, 2014 - 8:32pm
Permalink
I am trying too import
I am trying too import missing
Can't load library: C:\Users\Admin\.swt\lib\win32\x86_64\swt-win32-4427.dll
Can't load library: C:\Users\Admin\.swt\lib\win32\x86_64\swt-win32.dll
but still facing with error. Any idas?
kostyanius (not verified)
Wednesday, August 6, 2014 - 8:45pm
Permalink
Done. Import is finished.
Done. Import is finished.
But now error has chenged.
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Display cannot be resolved to a type
Display cannot be resolved to a type
Shell cannot be resolved to a type
Shell cannot be resolved to a type
Java text is:
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
public class HelloWorldSwt {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("Hello, world!");
shell.open();
// Set up the event loop.
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) {
// If no more entries in the event queue
display.sleep();
}
}
display.dispose();
}
}
Add new comment