Import SWT as a Gradle dependency

好久不见. 提交于 2019-12-07 16:05:36

You have to use the whole package name in the dependency line, including the version number.

Therefore add: compile "org.eclipse:swt:3.3.0-v3346" to the build.gradle file.

When using jcenter with Gradle for compiling Eclipse SWT.

The Repository that Gradle pulls from for SWT is JCenter SWT.

Edit your gradle.build accordingly. You need to add the compile line to the dependencies closure of your Grable.build. For example, if you want to build for 64 bit Linux use:

compile 'org.eclipse.swt:org.eclipse.swt.gtk.linux.x86_64:4.3'

According to Eclipse Foundation,

SWT is an open source widget toolkit for Java designed to provide efficient, portable access to the user-interface facilities of the operating systems on which it is implemented.

This means that unlike other Java GUI tool kits like Swing, SWT does not provide its own widgets, but allows you to write one Java UI that can use with a platform specific implementation of SWT for the desired OS, like windows or mac.

For you desired Operating System, you will want to select the corresponding library version from JCenter SWT, where the compile line from gradle.buildshould reflect:

compile 'org.eclipse.swt:<target platform>:4.3'

Where <target platform> for example is org.eclipse.swt.cocoa.macosx.x86_64/ or org.eclipse.swt.win32.win32.x86_64/.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!