How do you build an SWT application with Maven
I trying to learn swt, and I use maven for all my builds and eclipse for my IDE. When getting the swt jars out of the maven repository, I get:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-pi-gtk-3034 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1709)
at java.lang.Runtime.loadLibrary0(Runtime.java:823)
at java.lang.System.loadLibrary(System.java:1030)
at org.eclipse.swt.internal.Library.loadLibrary(Library.java:100)
at org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:19)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:63)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:54)
at org.eclipse.swt.widgets.Display.<clinit>(Display.java:112)
at wenzlick.test.swt.main.Main.main(Main.java:30)
Has anyone successfully got a swt app to build and run using maven?
Edit: I did a little research and found the problem. look at my post below
Asked by: Catherine427 | Posted: 28-01-2022
Answer 1
I have uploaded the win32/64 & osx artifacts of the latest SWT version (4.2.2) to a googlecode repository, you can find it here:
https://swt-repo.googlecode.com/svn/repo/
To use it just put the following in your pom.xml:
<repositories>
<repository>
<id>swt-repo</id>
<url>https://swt-repo.googlecode.com/svn/repo/</url>
</repository>
</repositories>
Then you can just reference the SWT dependency relevant to your platform. For example:
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86</artifactId>
<version>4.2.2</version>
</dependency>
For other platforms, just replace artifactId with the appropriate value:
- org.eclipse.swt.win32.win32.x86
- org.eclipse.swt.win32.win32.x86_64
- org.eclipse.swt.cocoa.macosx
- org.eclipse.swt.cocoa.macosx.x86_64
Artifacts for additional platforms and older versions are available as well, visit the repository link above to find them.
Happy coding!
Answered by: Catherine395 | Posted: 01-03-2022Answer 2
Sounds like Maven is pulling in an old version of SWT. As of v3.4 (and higher), the swt.jar is all you need. SWT will automatically extract the .so
s, .jnilib
s or .dll
s as necessary. The only tricky thing you need to worry about is to ensure that you get the right swt.jar (meaning for your platform).
Try installing SWT 3.4 in your local repository by hand. If that still gives you the same problem, then something is probably fishy. After that, I would try extracting the .so
s manually and then specifying the java.library.path
variable using the -D
switch on invocation. Sometimes on Linux the loading of the libraries can fail due to dependency problems (in things like libpango). In such cases, often the error will be just the generic UnsatisifedLinkError
, making the problem difficult to debug.
Answer 3
Since 2013 (this post inception year), things has changed. SWT is now published on Maven Central. Here are the coordinates as of this writing:
<dependency>
<groupId>org.eclipse.platform</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>
<version>${swt.version}</version>
</dependency>
You may find this ticket interesting.
Latest SWT artefacts for windows 64bit: https://mvnrepository.com/artifact/org.eclipse.platform/org.eclipse.swt.win32.win32.x86_64
Answered by: Briony646 | Posted: 01-03-2022Answer 4
From the API of UnsatisfiedLinkError
Thrown if the Java Virtual Machine cannot find an appropriate native-language definition of a method declared native.
I haven't tried it myself, but I think you not only need to download the main SWT jar, but a supporting 'native' JAR for your platform. For example swt-linux-gtk if you're on Linux?
Answered by: Daryl975 | Posted: 01-03-2022Answer 5
I used github with latest Eclipse's stuff: https://github.com/maven-eclipse/maven-eclipse.github.io . I suggest you read that.
The pom.xml that worked for me:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.whatever</groupId>
<artifactId>whatever</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>swt</name>
<url>http://maven.apache.org</url>
<repositories>
<repository>
<id>maven-eclipse-repo</id>
<url>http://maven-eclipse.github.io/maven</url>
</repository>
</repositories>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<swt.version>4.6</swt.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<!-- select prefered one, or move the preferred on to the top: -->
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86_64</artifactId>
<version>${swt.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.win32.win32.x86</artifactId>
<version>${swt.version}</version>
<!-- To use the debug jar, add this -->
<classifier>debug</classifier>
</dependency>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.gtk.linux.x86</artifactId>
<version>${swt.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.gtk.linux.x86_64</artifactId>
<version>${swt.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.cocoa.macosx.x86_64</artifactId>
<version>${swt.version}</version>
</dependency>
</dependencies>
</project>
Answered by: David550 | Posted: 01-03-2022
Answer 6
I did a little more research on this and found that the swt jar is in a couple different places in the maven repository. I was using jars put out by the swt group, but after looking around a bit, I found the jars put out by the org.eclipse.swt.gtk.linux group for linux (org.eclipse.swt.win32.win32 for Windows). This is for the 3.3 version of swt. Still looking for 3.4.
Answered by: Fenton945 | Posted: 01-03-2022Similar questions
orm - How to build a java web application
Soon I will have to start a web project for a company, and I now need to choose a technology to build the app.
I'm thinking about using Java, hence I'd like to find a framework that will help me building the app (I'm used to PHP framework such as CakePHP & CodeIgniter).
What I don't understand is that it seems to exist a lot of framework and technologies that don't have the same goal. Action framework, Componen...
java - How to Build an SDK for my application?
I am coding a JAVA project and I want to create an SDK to be used with Eclipse. How could I build one?
My project is actually a backbone of 20+ functions. I want to provide and SDK for the developers to develop above this backbone, just like how developers use ANDROID SDK. So how can I make an SDK?
file - How to get path after build java application
Hello when i clean a build application "Application.jar" how i can get path to file with this application folder for example I have builded this aplication in
D:/Application/Application.jar
and want get path
D:/Application/files/text.txt
but I dont want to use file chooser I want automatic path. Thanks for answers.
java - Cannot build JavaFX application using Ant
I need to create build file for ant to build my JavaFX project, I have searched a lot, but nothing helped me. It still show errors but compiles. When I tries to run jar file - exceptions. I have tried different paths, but still nothing.
Here is my build.xml.
<?xml version="1.0" encoding="UTF-8" ?>
<project name="JDBC Ant Project" default="default" basedir="." xmlns:**fx="javafx:com.sun.j...
windows - IE6 generated strange worksheet name when doing export from java application
I am encountering error like
test(10)[1].csv file cannot be found at
C:\Documents and Settings\Ron\Local Settings\Temporary Internet Files\Content.IE5\PQ0STUVW
When trying to do export of CSV file using the following codes.
Anyone have any idea what could be wrong? This issue does not occur in IE7 / Firefox and is only specific to IE6.
response.setContentType("applicati...
c# - Embedding Flash Player in a C++ or Java application?
I would like to embed Flash Player directly inside a C++ or Java application.
I found an article that describes how to do this for C#:
http://www.adobe.com/devnet/flash/articles/stock_history03.html
Unfortunately, I have no experience with C#, COM or ActiveX. I need someone to translate this code to C++, allowing ...
java - How best to implement user selectable variables in web application
I have a Java based web-application and a new requirement to allow Users to place variables into text fields that are replaced when a document or other output is produced. How have others gone about this?
I was thinking of having a pre-defined set of variables such as :
@BOOKING_NUMBER@
@INVOICE_NUMBER@
Then when a user enters some text they can specify a variable inline ...
java - BIRT in a desktop application
Did someone ever used a BIRT report in a desktop application. I'm comming from the .NET environment and there you can use Crystal Reports to show reports in desktop apps. Is this possible with BIRT too, without having to set up a server environment?
Can you give me some advice how to reach this goal?
Thanks in advance.
which library better for faster java application swt or swing?
which library better for faster java application swt or swing?
java - Which is the best Open source application server?
java - Access spring bean that is exposed using http invoker from GWT application
Can I access spring bean that exposed using http invoker (server) from GWT application (client)?
If so is there any example / tutorial for that?
How to close a Java Swing application from the code
What is the proper way to terminate a Swing application from the code, and what are the pitfalls?
I'd tried to close my application automatically after a timer fires. But just calling dispose() on the JFrame didn't do the trick - the window vanished but the application did not terminate. However when closing the window with the close button, the application does terminate. What should I do...
java - How best can I isolate my application from an unreliable database?
I have a Java SOAP data service which sits on top of a Sybase database which, for reasons out of my control, has unreliable performance. The database is part of a vendor package which has been modified by an internal team and most of the issues are caused by slow response times at certain times of the day.
The SOAP service provides data to a calculation grid and when I request data, I need the response time to be ...
java - Netbeans GUI Designer & Fixed-Size Application Panels
I'm having a problem, creating a fixed-size overall panel for a touchscreen GUI application that has to take up the entire screen. In a nutshell, the touchscreen is 800 x 600 pixels, and therefore I want the main GUI panel to be that size.
When I start a new GUI project in NetBeans, I set the properties of the main panel for min/max/preferred size to 800 x 600, and the panel within the 'Design' view changes size. ...
Still can't find your answer? Check out these amazing Java communities for help...
Java Reddit Community | Java Help Reddit Community | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)