Spider
Spider

Reputation: 1470

Could not load SWT library in Eclipse in Mac

When I tried to run a plug-in project as Eclipse Application, I get following error.

eclipse.buildId=unknown
java.version=1.8.0_152
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.platform.ide
Command-line arguments:  -product org.eclipse.platform.ide -data /{HOME}/eclipse-workspace/../runtime-New_configuration -dev file:/{HOME}/eclipse-workspace/.metadata/.plugins/org.eclipse.pde.core/New_configuration/dev.properties -os win32 -ws win32 -arc$

!ENTRY org.eclipse.osgi 4 0 2017-12-07 23:43:27.145
!MESSAGE Application error
!STACK 1
java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
        no swt-win32-4530 in java.library.path
        no swt-win32 in java.library.path
        Can't load library: /{HOME}/.swt/lib/macosx/x86_64/libswt-win32-4530.jnilib
        Can't load library: /{HOME}/.swt/lib/macosx/x86_64/libswt-win32.jnilib

        at org.eclipse.swt.internal.Library.loadLibrary(Library.java:327)
        at org.eclipse.swt.internal.Library.loadLibrary(Library.java:236)
        at org.eclipse.swt.internal.C.<clinit>(C.java:16)
        at org.eclipse.swt.widgets.Display.<clinit>(Display.java:138)
        at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:774)
        at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:162)
        at org.eclipse.ui.internal.ide.application.IDEApplication.createDisplay(IDEApplication.java:169)
        at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:111)
        at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
        at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
        at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
        at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)

Then, I found out that the folder "/{HOME}/.swt/lib/macosx/x86_64" acctually is empty. I guess this is the reason, but I do not know how to reinstall SWT(I have googled a while though)

Eclipse Version: Oxygen.1a Release (4.7.1a) (64-bit)

Java Version:

java version "1.8.0_152"
Java(TM) SE Runtime Environment (build 1.8.0_152-b16)
Java HotSpot(TM) 64-Bit Server VM (build 25.152-b16, mixed mode)

Mac Version: 10.12 (64-bit)

Upvotes: 1

Views: 2175

Answers (1)

greg-449
greg-449

Reputation: 111142

The command line arguments:

-os win32 -ws win32

show that you are trying to run this as a Windows application - which isn't going to work on macOS

Check that the Arguments tab of the Run Configuration has something like:

-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} 

in the program arguments and that the 'Environment' section of your current Target Platform is blank or specifies macOS.

Upvotes: 3

Related Questions