How to run SWT project using Netbeans?

I get run time exception:

Exception in thread "main" java.lang.UnsatisfiedLinkError: no swt-pi-gtk-3236 in java.library.path

at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1682)

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:123)

at org.eclipse.swt.internal.gtk.OS.<clinit>(OS.java:22)

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:126)

at swttest.Main.formLayout(Main.java:41)

at swttest.Main.main(Main.java:36)

Java Result: 1

thanks;

[794 byte] By [meirwinstona] at [2007-11-27 11:56:40]
# 1

did you put the SWT library in your project path?

mark07a at 2007-7-29 19:08:53 > top of Java-index,Java Essentials,Java Programming...
# 2

yes, I directed the project to the swt jars

meirwinstona at 2007-7-29 19:08:53 > top of Java-index,Java Essentials,Java Programming...
# 3

could always try putting the jar files directly in your project

right click on your project go to properties>libraries>add Jar files other than that not sure

mark07a at 2007-7-29 19:08:53 > top of Java-index,Java Essentials,Java Programming...
# 4

I did that, thank you anyway, I think it has to do with other swt files that are suppose to be binded to the GTK

meirwinstona at 2007-7-29 19:08:53 > top of Java-index,Java Essentials,Java Programming...
# 5

> yes, I directed the project to the swt jars

SWT consists of jars and native libraries

georgemca at 2007-7-29 19:08:53 > top of Java-index,Java Essentials,Java Programming...
# 6

I don't know how to direct Netbeans to the native libraries

meirwinstona at 2007-7-29 19:08:53 > top of Java-index,Java Essentials,Java Programming...
# 7

Can I ask why you're developing SWT in NetBeans? I'm not saying it shouldn't be done, or anything, just curious as to why that decision was made!

georgemca at 2007-7-29 19:08:53 > top of Java-index,Java Essentials,Java Programming...
# 8

for no particular reason, I use eclipse as well, but I feel more comfortable with netbeans

meirwinstona at 2007-7-29 19:08:53 > top of Java-index,Java Essentials,Java Programming...
# 9

> for no particular reason, I use eclipse as well, but

> I feel more comfortable with netbeans

Reasonable enough reason!

georgemca at 2007-7-29 19:08:53 > top of Java-index,Java Essentials,Java Programming...
# 10

> yes, I directed the project to the swt jars

You need to add the swt jar files to both the project build and project run/debug class path. Exactly how you do this depends on the type of project you've created. The simplest way to add them to the netbean lib directory. The best way is to create a ant script to do it.

MartinS.a at 2007-7-29 19:08:53 > top of Java-index,Java Essentials,Java Programming...
# 11

> > yes, I directed the project to the swt jars

>

> You need to add the swt jar files to both the project

> build and project run/debug class path. Exactly how

> you do this depends on the type of project you've

> created. The simplest way to add them to the netbean

> lib directory. The best way is to create a ant

> script to do it.

Have you tried this specifically with SWT? Did it work?

georgemca at 2007-7-29 19:08:53 > top of Java-index,Java Essentials,Java Programming...
# 12

UnsatisfiedLinkError is a native library error, not classpath error, not to mention it's very common when starting to work with SWT. I've never tried SWT with NetBeans, in fact I don't use NetBeans much at all, I use Eclipse, personal preference, I've tried NetBeans but I'm just more comfortable with Eclipse. Anyway, to get this to work you need to add this argument to the launch configuration:

-Djava.library.path=*path to the SWT dlls*

There should be 3 of them and you just have to put the path to that directory, not each individual DLL.

Being unfamiliar with NetBeans I can't tell you exactly how to do this, but I assume there is some sort of launch dialog where you can specify JVM arguments. Hopefully this helps.

m_roznera at 2007-7-29 19:08:53 > top of Java-index,Java Essentials,Java Programming...