Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » Help needed with link error(Running the HelloWorldSWT and I get runtime error)
Help needed with link error [message #691914] Sat, 02 July 2011 19:33 Go to next message
mark is currently offline mark
Messages: 3
Registered: July 2011
Junior Member
I followed all the instructions in the HelloWorldSWT tutorial and I keep getting a link error. Here is what I get when I run the application:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-win32-3735 in java.library.path
no swt-win32 in java.library.path
Can't load library: C:\Users\Mark\.swt\lib\win32\x86\swt-win32-3735.dll
Can't load library: C:\Users\Mark\.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:12)

I've tried all sorts of things to no avail (even moving my workspace, which didn't help). Any ideas?

Thanks!
Mark
Re: Help needed with link error [message #692772 is a reply to message #691914] Tue, 05 July 2011 07:54 Go to previous messageGo to next message
gz4have is currently offline gz4have
Messages: 1
Registered: July 2011
Junior Member
You should set the java.library.path variable first.
Right click your project and go to Run as->Run Configurations->Arguments->VM arguments.
Then type in the text field: -Djava.library.path=your eclipse directory\plugins
Hope this works fine for u Razz
Re: Help needed with link error [message #692804 is a reply to message #692772] Tue, 05 July 2011 09:17 Go to previous messageGo to next message
LaosLos  is currently offline LaosLos
Messages: 1
Registered: July 2011
Junior Member
Hi all,

I found the same problem with the HelloWorldSWT tuto. I've done what you said and now I find a new error Sad :

java.lang.NoClassDefFoundError: de
Caused by: java.lang.ClassNotFoundException: de
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"

Thank you very much for your help

Laos
Re: Help needed with link error [message #692970 is a reply to message #692804] Tue, 05 July 2011 15:06 Go to previous messageGo to next message
David Wegener is currently offline David Wegener
Messages: 1344
Registered: July 2009
Senior Member
Put quotes around your VM arguments -Djava.library.path="path to library"
Re: Help needed with link error [message #693009 is a reply to message #692970] Tue, 05 July 2011 16:00 Go to previous messageGo to next message
mark is currently offline mark
Messages: 3
Registered: July 2011
Junior Member
Still no change for me. I added the following:

-Djava.library.path="C:\eclipse\plugins"

in the VM Arguments section of the Arguments tab. I'm using Eclipse 3.7 on Windows Vista.

I have my workspace set up as "C:\workspace". Is there something I should point to there instead?
Re: Help needed with link error [message #694125 is a reply to message #693009] Thu, 07 July 2011 21:26 Go to previous messageGo to next message
Daren Scot Wilson is currently offline Daren Scot Wilson
Messages: 7
Registered: July 2011
Junior Member
I have the same problem as the OP, except I'm on Linux not Windows. Did the -D thing, no change. A clue might be that when the java source compiles, I get a warning:

Quote:

Build path specifies execution environment CDC-1.0/Foundation-1.0. There are no JREs installed in the workspace that are strictly compatible with this environment. org.eclipse.swt.gtk.linux.x86_64 Build path JRE System Library Problem


Another clue, or maybe irrelevant, is when I try "java HelloWorldSWT" at the command line, I get:

Quote:

Exception in thread "main" java.lang.NoClassDefFoundError: org/eclipse/swt/widgets/Display at HiMarsSwt.main(HiMarsSwt.java:12)
(note: i called my latest attempt "HiMarsSwt" not "HelloWorldSWT")


One notion in my software-experienced but java-naive mind is that somehow SWT isn't installed, that it needs to be installed separately from the jdk. Guessing that if SWT truly exists, there'd be a file, probably many, with "swt" in their names, I tried:

dwilson ~ ===> cd SW/SDK/jdk1.6.0_26
dwilson ~/SW/SDK/jdk1.6.0_26 ===> find . -iname '*swt*'
dwilson ~/SW/SDK/jdk1.6.0_26 ===> 

(To be clear, that means no files found.)

Eclipse's directory does show about a dozen files, including one mentioned in the link error, libswt-gtk-3735.so (The OP has Windows, I'm on Linux, aside from that it's the same file) Maybe some path somewhere needs to be fixed?


Re: Help needed with link error [message #694129 is a reply to message #694125] Thu, 07 July 2011 21:34 Go to previous messageGo to next message
mark is currently offline mark
Messages: 3
Registered: July 2011
Junior Member
I went ahead and searched for swt.dll on my windows Vista machine. After finding the dll's, I then added the following line to the configuration:

-Djava.library.path="C:\eclipse\configuration\org.eclipse.osgi\bundles\157\1\.cp"

It now works, but I assume there is a more "correct" way to do this. Any thoughts?

Thanks!
Mark
Re: Help needed with link error [message #694161 is a reply to message #694129] Thu, 07 July 2011 23:53 Go to previous messageGo to next message
Daren Scot Wilson is currently offline Daren Scot Wilson
Messages: 7
Registered: July 2011
Junior Member
Hooray! Same success here, too.

Yeah, a funny looking directory path like that looks like something us Eclipse non-gurus shouldn't be messing with. There probably is a proper way to fix it.

But for now, I'm moving on to the next tutorial...
Re: Help needed with link error [message #694236 is a reply to message #694161] Fri, 08 July 2011 07:18 Go to previous messageGo to next message
Lars Briem is currently offline Lars Briem
Messages: 20
Registered: June 2011
Junior Member
Hello,

a more comfortable solution would be to copy the swt libraries in your project and add them to the buildpath. You can find the libraries in your eclipse\plugins directory. The libraries you need start with: org.eclipse.swt

This is useful if you want to hand out your program to someone else, because you do not know if he has eclipse installed and where it might be.

greetings Lars
Re: Help needed with link error [message #694472 is a reply to message #694236] Fri, 08 July 2011 16:54 Go to previous messageGo to next message
Daren Scot Wilson is currently offline Daren Scot Wilson
Messages: 7
Registered: July 2011
Junior Member
Is SWT actually provided by Eclipse? I had been assuming it's a standard part of JDK/JRE, though by this misadventure I see this is not so. How do people running Java apps using SWT normally get SWT if they don't have Eclipse?
Re: Help needed with link error [message #695252 is a reply to message #694472] Mon, 11 July 2011 11:37 Go to previous messageGo to next message
Lars Briem is currently offline Lars Briem
Messages: 20
Registered: June 2011
Junior Member
On the swt site under releases you can download the jars for the different os.
http://www.eclipse.org/swt/
Re: Help needed with link error [message #697973 is a reply to message #695252] Mon, 18 July 2011 13:58 Go to previous messageGo to next message
Ashish Solanki is currently offline Ashish Solanki
Messages: 1
Registered: July 2011
Junior Member
I fallowed Mark's solution and it works for me, I suggest copy that two .dlls from your eclipse installed location "DRIVE:\eclipse\configuration\org.eclipse.osgi\bundles\157\1\.cp" to the path where it shows missing. In case of mark it will be "C:\Users\Mark\.swt\lib\win32\x86\" .

Seems it will be more specific solution and need not to add every time in your project.

All the best
Re: Help needed with link error [message #718446 is a reply to message #691914] Wed, 24 August 2011 11:03 Go to previous messageGo to next message
Pete  is currently offline Pete
Messages: 1
Registered: August 2011
Junior Member
Had Same initial issue and finally sorted it by...

Right click on project and go to Properties

In Java Build Path under the Projects tab there is the associated Project, in my case org.eclipse.swt.win32.win32.x86

Expand this down with the little arrow to the left to display the options. Here I found Native Library Locations. This wasn't set so I selected it and clicked Edit.

In the Popup window that follows, I selected Workspace and then org.eclipse.swt.win32.win32.x86.

Next time I ran the class, it work fine.

I hope this helps someone!

Re: Help needed with link error [message #720657 is a reply to message #718446] Wed, 31 August 2011 02:46 Go to previous messageGo to next message
Kevin  is currently offline Kevin
Messages: 2
Registered: August 2011
Junior Member
Pete... thanks!

Your solution was by far the most straightforward. I was pulling my hair out until I Googled to see if anyone else ran into this. I am pretty new to Eclipse and find it overwhelming, and had no clue what to do with this error. Eclipse seems to need to have so many things "magically" set up to make something work that it is a bit scary to me.

I wonder if this is simply a missing step in the Hello World SWT application tutorial or is this something that Eclipse users are expected to just automatically know somehow? Like from some other previous tutorial or education session that we all missed?

If any Eclipse experts out there could add some basic education in this area as to how we are really supposed to avoid pitfalls like this in the future, I'm all ears. I'm hoping I can get to know Eclipse well enough to do some productive things with it soon.

Thanks again for helping me move past this error.
Re: Help needed with link error [message #727261 is a reply to message #718446] Tue, 20 September 2011 18:35 Go to previous messageGo to next message
LucaMaz  is currently offline LucaMaz
Messages: 1
Registered: September 2011
Junior Member
Pete...thanks a lot! Now it works.

Thank again for your help.
Re: Help needed with link error [message #727333 is a reply to message #727261] Wed, 21 September 2011 01:27 Go to previous messageGo to next message
schutjer Missing name is currently offline schutjer Missing name
Messages: 1
Registered: September 2011
Junior Member
Pete - and Mark, Thanks. Both worked for me. Pete's seemed a little more elegant.
Thanks again.
Re: Help needed with link error [message #894132 is a reply to message #718446] Fri, 06 July 2012 20:30 Go to previous messageGo to next message
Peter Newell is currently offline Peter Newell
Messages: 1
Registered: July 2012
Junior Member
Pete

Just wanted to say - your message re "no swt-gtk-3740 in java.library.path" message etc sorted it out for me. Using Version: 3.7.2 of sdk. So thanks.
Re: Help needed with link error [message #977577 is a reply to message #718446] Fri, 09 November 2012 11:45 Go to previous message
Stephen Hutchinson is currently offline Stephen Hutchinson
Messages: 1
Registered: November 2012
Junior Member
Yes, worked for me too. Razz

Been faffing around for hours trying all sorts of stuff but this worked. Great! Thanks.

Now all I need is an explanation of why it works.
Previous Topic:Deployment Problem
Next Topic:How to disable/enable view toolbar menu/action in Eclipse Plugin Development
Goto Forum:
  


Current Time: Thu Oct 23 06:06:36 GMT 2014

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

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