Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Hello World SWT - Could not load SWT library(Can't run the first tutorial )
Hello World SWT - Could not load SWT library [message #754988] Sun, 06 November 2011 12:59 Go to next message
willem  is currently offline willem Friend
Messages: 2
Registered: November 2011
Junior Member
Hello All,

I just "installed" Eclipse for RCP and RAP Developers and wanted to do the "Hello World SWT" tutorial.

I am getting the following error when i run the application.

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\Willem\.swt\lib\win32\x86\swt-win32-3738.dll
	Can't load library: C:\Users\Willem\.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)

I think this might has something to do with my %PATH% variable, or my runtime environment , but i'm not really sure.

I downloaded the latest java JDK from the oracle site ( Java SE 7u1 )

I updated my eclipse.ini , as suggested in the newcomers sticky .
My eclipse.ini file looks like this:
-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
-product
org.eclipse.epp.package.rcp.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vm
C:\Program Files\Java\jdk1.7.0_01\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx512m


I am running windows 7 professional 32 bit.

Any help would be greatly appreciated, thanks in advanced !

[Updated on: Sun, 06 November 2011 14:30]

Report message to a moderator

Re: Hello World SWT - Could not load SWT library [message #754994 is a reply to message #754988] Sun, 06 November 2011 14:16 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

On 2011.11.06 5:59, willem wrote:
> Hello All,
>
> I just "installed" Eclipse for RCP and RAP Developers and wanted to do
> the "Hello World SWT" tutorial.
>
> [snip]
>
> I updated my eclipse.ini , as suggested in the newcomers sticky .
> My eclipse.ini file looks like this:
> -startup
> plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
> --launcher.library
> plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.100.v20110502
> -product
> org.eclipse.epp.package.rcp.product
> --launcher.defaultAction
> openFile
> --launcher.XXMaxPermSize
> 256M
> -showsplash
> org.eclipse.platform
> --launcher.XXMaxPermSize
> 256m
> --launcher.defaultAction
> openFile
> -vmargs
> -Dosgi.requiredJavaVersion=1.5
> -Xms40m
> -Xmx512m
> -vm
> C:\Program Files\Java\jdk1.7.0_01\bin\javaw.exe
> I added the last two lines, but that doesn't seem to do anything.
> I am running windows 7 professional 32 bit.
>
> Any help would be greatly appreciated, thanks in advanced !

Hey, this may be a little off-topic (i.e.: it may not cure your original
complaint), but I'm pretty sure that you must put

-vm
C:\Program Files\Java\jdk1.7.0_01\bin\javaw.exe

before the -vmargs section in eclipse.ini.
Re: Hello World SWT - Could not load SWT library [message #754995 is a reply to message #754994] Sun, 06 November 2011 14:28 Go to previous messageGo to next message
willem  is currently offline willem Friend
Messages: 2
Registered: November 2011
Junior Member
Hi Russell, thanks for noticing that, i changed it, but it doesn't seem to solve the problem.
Re: Hello World SWT - Could not load SWT library [message #761182 is a reply to message #754988] Tue, 06 December 2011 03:28 Go to previous messageGo to next message
TheCric  is currently offline TheCric Friend
Messages: 1
Registered: December 2011
Junior Member
Hello

I have got exactly the same problem! Bad for a first SWT example for newbies Confused

Anyway there is a working solution Razz for me (My SDK is eclipse-SDK-3.7.1-win32.zip)

Follow the explanations given on the link below
to add swt-3.7.1-win32-win32-x86.zip to your Eclipse
(in case you are in Windows 32bit)

www.badprog.com/eclipse-standard-widget-toolkit-swt-installation

There are probably other solutions using the java.library.path

lol : I cannot use links until I have posted more than 5 messages so you may have to add h t t p : / / by yourself.

Another collateral damage of the war against spam...




Re: Hello World SWT - Could not load SWT library [message #762787 is a reply to message #761182] Thu, 08 December 2011 16:16 Go to previous messageGo to next message
Heimdall  is currently offline Heimdall Friend
Messages: 3
Registered: December 2011
Junior Member
The solution didn't work for me. First it told me that it couldn't add the project that was already there, org.eclipse.swt. So I deleted org.eclipse.swt and org.eclipse.swt.win32.win32.x86 and tried that import again. But it only added org.eclipse.swt and not org.eclipse.swt.win32.win32.x86, which I still had to add again the way the tutorial tells. Not working, so again I tried just deleting org.eclipse.swt and following the "solution" instructions again.

After another whinge that swt-win32-3738 was not found (even thought it is in Workspace\org.eclipse.swt.win32.win32.x86 as a .dll), I picked on the message
Can't load library: .swt\lib\win32\x86\swt-win32-3738.dll
and copied the file there. Now it works. But something doesn't feel right.

It seems to me that this is not meant to be the solution. If the file belongs there, why wasn't it there in the first place? If it doesn't, my solution is dirty/messy, especially is I have to do the same thing again and again. Anyway, the file is in the root of the project org.eclipse.swt.win32.win32.x86, so why wasn't it used from there? Does it really belong there? Are some paths set wrong? Is the problem in the project itself or in Eclipse?

In short - what is wrong / what am I doing wrong? Help!

Tom
Re: Hello World SWT - Could not load SWT library [message #794878 is a reply to message #762787] Thu, 09 February 2012 20:24 Go to previous messageGo to next message
Craig Williams is currently offline Craig WilliamsFriend
Messages: 1
Registered: February 2012
Junior Member
Hi,

I found this thread after trying the HelloWorldSWT tutorial myself and coming across the exact same problem.

For me the solution lay in the step of the tutorial titled 'Configure the Java project'. Go into the project Properties and select Java Build Path then make sure you are in the Projects tab where you added the SWT project earlier. Expand the reference to the SWT project. Where is says Native library location I found that when I followed the tutorial it said (None). I clicked Edit and found the SWT project in my workspace obviously when I added it earlier in the tutorial. Select this and click OK.

Your project should now be able to run.
Re: Hello World SWT - Could not load SWT library [message #797514 is a reply to message #794878] Mon, 13 February 2012 15:33 Go to previous messageGo to next message
Eclipse UserFriend
I need help too
Re: Hello World SWT - Could not load SWT library [message #797517 is a reply to message #797514] Mon, 13 February 2012 15:35 Go to previous messageGo to next message
Eclipse UserFriend
I'm studying a guide book, a chapter describes a project to add:
Right-click on the package of the project - properties - android - Add..., but does not allow me to add the library. Please Help
Re: Hello World SWT - Could not load SWT library [message #797518 is a reply to message #797517] Mon, 13 February 2012 15:35 Go to previous messageGo to next message
Eclipse UserFriend
ttp://img607.imageshack.us/img607/7131/immaginexca.jpg
icon14.gif  Re: Hello World SWT - Could not load SWT library [message #824856 is a reply to message #794878] Tue, 20 March 2012 06:35 Go to previous messageGo to next message
Ken Ho is currently offline Ken HoFriend
Messages: 1
Registered: March 2012
Junior Member
Thanks Craig, that fixed it.
icon14.gif  Re: Hello World SWT - Could not load SWT library [message #833776 is a reply to message #794878] Sun, 01 April 2012 01:48 Go to previous messageGo to next message
Dee Landergren is currently offline Dee LandergrenFriend
Messages: 1
Registered: April 2012
Junior Member
Thanks from me too -
icon14.gif  Re: Hello World SWT - Could not load SWT library [message #834359 is a reply to message #833776] Sun, 01 April 2012 21:18 Go to previous messageGo to next message
Pablo Carreño is currently offline Pablo CarreñoFriend
Messages: 1
Registered: April 2012
Junior Member
Thanks a lot!
Re: Hello World SWT - Could not load SWT library [message #868522 is a reply to message #834359] Wed, 02 May 2012 06:29 Go to previous messageGo to next message
Peter Huppertz is currently offline Peter HuppertzFriend
Messages: 1
Registered: May 2012
Junior Member
And another thank you to Craig Williams.
icon14.gif  Re: Hello World SWT - Could not load SWT library [message #870608 is a reply to message #868522] Wed, 09 May 2012 00:36 Go to previous messageGo to next message
Bo Xu is currently offline Bo XuFriend
Messages: 1
Registered: May 2012
Junior Member
Thanks Craig Williams. The problem solved. Was trying to download SWT package to install, but, this is much quicky solution and at least we know the SWT came with the package is not broken.
Re: Hello World SWT - Could not load SWT library [message #876141 is a reply to message #794878] Thu, 24 May 2012 01:36 Go to previous messageGo to next message
j w is currently offline j wFriend
Messages: 1
Registered: May 2012
Junior Member
Yes, that worked, after several tries. Thank you Craig.
Re: Hello World SWT - Could not load SWT library [message #900079 is a reply to message #754988] Fri, 03 August 2012 20:10 Go to previous messageGo to next message
Jae-Hun Jung is currently offline Jae-Hun JungFriend
Messages: 1
Registered: August 2012
Junior Member
To Craig Williams..
Thanks! I solved it!
icon14.gif  Re: Hello World SWT - Could not load SWT library [message #901042 is a reply to message #794878] Thu, 09 August 2012 14:07 Go to previous messageGo to next message
Jason Farmer is currently offline Jason FarmerFriend
Messages: 1
Registered: August 2012
Junior Member
Thank you - that did the trick.
icon14.gif  Re: Hello World SWT - Could not load SWT library [message #909027 is a reply to message #754988] Thu, 06 September 2012 12:43 Go to previous messageGo to next message
Kim Strong is currently offline Kim StrongFriend
Messages: 1
Registered: September 2012
Junior Member
Thank you Craig Williams

Saved more than necessary head scratching.

Cheers.
Re: Hello World SWT - Could not load SWT library [message #977665 is a reply to message #754988] Fri, 09 November 2012 13:21 Go to previous messageGo to next message
Fausto Orso is currently offline Fausto OrsoFriend
Messages: 1
Registered: November 2012
Junior Member
Thank You Craig Williams!
Re: Hello World SWT - Could not load SWT library [message #984306 is a reply to message #977665] Wed, 14 November 2012 15:32 Go to previous messageGo to next message
Jim Graf is currently offline Jim GrafFriend
Messages: 1
Registered: November 2012
Junior Member
+1 Craig Williams, although for me it didn't really help - but now I know where that is!

I must of missed an installation step because the default place it was looking for the swt library was

$HOME/.swt/lib/linux/x86
and there weren't any libraries in there. So I did:

find ~/local/eclipse/ -name libswt\*.so -exec cp {} ~/.swt/lib/linux/x86/ \;


and now it runs fine without explicitly setting the location of the shared libs. I could have set the path explictly to where the libs were found in the eclipse directory, but they are at:

eclipse/configuration/org.eclipse.osgi/bundles/193/1/.cp


which is kind of an odd place, hidden directory and all.

-jim

Re: Hello World SWT - Could not load SWT library [message #991761 is a reply to message #794878] Thu, 20 December 2012 06:10 Go to previous messageGo to next message
Scott Franz is currently offline Scott FranzFriend
Messages: 1
Registered: December 2012
Junior Member
Craig Williams wrote on Thu, 09 February 2012 15:24
Hi,

I found this thread after trying the HelloWorldSWT tutorial myself and coming across the exact same problem.

For me the solution lay in the step of the tutorial titled 'Configure the Java project'. Go into the project Properties and select Java Build Path then make sure you are in the Projects tab where you added the SWT project earlier. Expand the reference to the SWT project. Where is says Native library location I found that when I followed the tutorial it said (None). I clicked Edit and found the SWT project in my workspace obviously when I added it earlier in the tutorial. Select this and click OK.

Your project should now be able to run.


You sir are a godsend. I'm pretty new to CS and I've been wreaking my brain for 3 days trying to figure this out.

Since the instructions were a little vague I'll will try to restate what he said:

In Package Exporer >> Right click your SWT project >> Properties >> On the left pane, select "Java Build Path" >> In the right window go to the "Projects" tab >> Expand the "org.eclipse.swt.win32.win32.x86" project in the box >> Select "Native Library Location" >> Click on "Edit" on the right hand side >> Click on "Workspace" >> Select the "org.eclipse.swt.win32.win32.x86" object (don't expand it) >> click "OK"

Thanks again!
icon14.gif  Re: Hello World SWT - Could not load SWT library [message #1032917 is a reply to message #794878] Wed, 03 April 2013 16:05 Go to previous messageGo to next message
Carl Verbiest is currently offline Carl VerbiestFriend
Messages: 3
Registered: October 2011
Junior Member
+1 Craig Williams
Re: Hello World SWT - Could not load SWT library [message #1061175 is a reply to message #794878] Thu, 30 May 2013 11:44 Go to previous messageGo to next message
Gentle Chan is currently offline Gentle ChanFriend
Messages: 2
Registered: May 2013
Junior Member
Hello.
How to "Expand the reference to the SWT project"? I'd appreciate it if you could show that in a picture. Thanks so much.
Re: Hello World SWT - Could not load SWT library [message #1116566 is a reply to message #794878] Wed, 25 September 2013 15:53 Go to previous messageGo to next message
Malcolm O\'Beirn is currently offline Malcolm O\'BeirnFriend
Messages: 1
Registered: September 2013
Junior Member
Thanks for that, Craig
Re: Hello World SWT - Could not load SWT library [message #1125555 is a reply to message #754988] Fri, 04 October 2013 16:42 Go to previous messageGo to next message
Jackie Silva is currently offline Jackie SilvaFriend
Messages: 1
Registered: October 2013
Junior Member
Thank you!!
Re: Hello World SWT - Could not load SWT library [message #1175664 is a reply to message #794878] Thu, 07 November 2013 22:44 Go to previous messageGo to next message
Sinisa Ristic is currently offline Sinisa RisticFriend
Messages: 1
Registered: November 2013
Junior Member
It worked! Thanks a lot!
Re: Hello World SWT - Could not load SWT library [message #1209378 is a reply to message #794878] Mon, 25 November 2013 13:34 Go to previous messageGo to next message
Peter Coghill is currently offline Peter CoghillFriend
Messages: 1
Registered: November 2013
Location: London
Junior Member
That worked for me! Many thanks.

It appears that the Native Lib Location defaults to blank - needs to be manually set.

Was a little frustrating for a total newb like me, but I learned something. Rolling Eyes


--------

Peter Coghill
@petecog
Re: Hello World SWT - Could not load SWT library [message #1215891 is a reply to message #794878] Thu, 28 November 2013 08:28 Go to previous messageGo to next message
Juzer Golwala is currently offline Juzer GolwalaFriend
Messages: 3
Registered: November 2013
Junior Member
Here's adding another thumbs up for Craig Williams!! Thank you.
Re: Hello World SWT - Could not load SWT library [message #1219971 is a reply to message #1215891] Sat, 07 December 2013 17:41 Go to previous messageGo to next message
Doug Shy is currently offline Doug ShyFriend
Messages: 1
Registered: December 2013
Junior Member
Good lord! Thanks a bunch to Craig, but his solution was posted over a year ago, and I just installed the latest Kepler and the tutorial is STILL broken.
Re: Hello World SWT - Could not load SWT library [message #1271362 is a reply to message #794878] Fri, 14 March 2014 23:56 Go to previous messageGo to next message
Kris Moore is currently offline Kris MooreFriend
Messages: 1
Registered: March 2014
Junior Member
Thank you so much, i have been rubbing my head for an hour or so trying to figure this out, Smile
Re: Hello World SWT - Could not load SWT library [message #1292343 is a reply to message #794878] Fri, 11 April 2014 18:46 Go to previous messageGo to next message
marco illescas is currently offline marco illescasFriend
Messages: 1
Registered: April 2014
Junior Member
Thanks!
Re: Hello World SWT - Could not load SWT library [message #1388771 is a reply to message #794878] Thu, 26 June 2014 23:24 Go to previous messageGo to next message
TJ Duez is currently offline TJ DuezFriend
Messages: 1
Registered: June 2014
Junior Member
Craig Williams wrote on Thu, 09 February 2012 15:24
Hi,

I found this thread after trying the HelloWorldSWT tutorial myself and coming across the exact same problem.

For me the solution lay in the step of the tutorial titled 'Configure the Java project'. Go into the project Properties and select Java Build Path then make sure you are in the Projects tab where you added the SWT project earlier. Expand the reference to the SWT project. Where is says Native library location I found that when I followed the tutorial it said (None). I clicked Edit and found the SWT project in my workspace obviously when I added it earlier in the tutorial. Select this and click OK.

Your project should now be able to run.


Long overdue, sure, but Craig Williams was (is?) genius on this point.

Fixed me!
Re: Hello World SWT - Could not load SWT library [message #1389316 is a reply to message #1388771] Fri, 27 June 2014 16:28 Go to previous message
Eric Rizzo is currently offline Eric RizzoFriend
Messages: 3070
Registered: July 2009
Senior Member
Topic locked to prevent more "Me too" or "Thanks!" posts.
Previous Topic:How to make your own tab indentation size
Next Topic:Eclipse EGit pushing latest commit hangs plink.exe
Goto Forum:
  


Current Time: Sat Dec 14 05:10:00 GMT 2024

Powered by FUDForum. Page generated in 0.11822 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top