2

I am very new to Java and I am trying to run a program I got from a friend. I keep getting this error and I'm unsure how to solve the problem.

Application is starting. Fetching data. Please wait... (approx. 10s) Exception in thread "main" java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: no swt-cocoa-4236 in java.library.path no swt-cocoa in java.library.path Can't load library: C:\Users\Andrew.swt\lib\win32\x86_64\swt-cocoa-4236.dll Can't load library: C:\Users\Andrew.swt\lib\win32\x86_64\swt-cocoa.dll

    at org.eclipse.swt.internal.Library.loadLibrary(Library.java:331)
    at org.eclipse.swt.internal.Library.loadLibrary(Library.java:240)
    at org.eclipse.swt.interal.C.<clinit>(C.java:21)
    at org.eclipse.swt.widgets.Display.<clinit>(Display.java:101)
    at view.MainWindow.open(MainWindow.java:77)
    at view.MainWindow.main(MainWindow.java:65)

Apparently I'm missing the SWT library (swt-cocoa-4236 and/or swt-cocoa?), but I have no idea where to get it. That statement probably reveals my ignorance. If anyone could even point me in the right direction to where I might be able to solve the problem I'd be very grateful. Thanks!

3 Answers 3

4

Seems like the program that you are running is not built for your OS. SWT is OS dependant and JVM depedant. All SWT programs will use swt.jar which will be different based on the underlying OS. The one the program is using is built for Mac OS and seems like you are running that on a non-Mac system.

Regarding 'How to solve it', it depends on how the program that you are running is packaged.

Check the java version you are using and download appropriate SWT jar file.

Sign up to request clarification or add additional context in comments.

15 Comments

Judging by the pathnames, the OP is running on Windows.
True, Windows, but again the JVM version will come into picture for Windows SWT
I completely forgot to mention I'm running Windows 7 but it seems I didn't need to. You must be a pro. Can you elaborate on what you mean by how the program is packaged?
How are you running the program? What is the folder structure of where the program is? Most probably there should be a lib folder where you can find the jar files. Look for swt jar file there.
I just put the program on my desktop after downloading it from Google drive. I've been running it from the command window using "java -jar". I don't see lib folder in the program folder.
|
2

I think Mubin (i.e. the above answer) is correct. here is where you can download the specific version of SWT.jar for your environment http://www.eclipse.org/swt/.

(I am answering your question for "I have no idea where to get it.")

2 Comments

Thank you this really helps. Are there any special installation instructions?
@DrewMerritt welcome, please feel free to give it 1+ for the answer for the usefulness. Happy I could help. There is a tutorial on the page eclipse.org/swt/docs.php.
0

little late to the game, but i just had the same problem and found this solution:

Here's what worked for me:

Right Click on your Project Folder of your HelloWorldSWT Project-> Properties -> Java Build Path -> Tab 'Projects'

Expand the 'org.eclipse.swt.cocoa.macosx.x86_64' folder by clicking on the arrow left to it

Select 'Native library location' and click Edit

Click the Workspace Button and select 'org.eclipse.swt.cocoa.macosx.x86_64', then click ok (serveral times).

That did the trick ... Ma-an

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.