By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,034 Members | 822 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,034 IT Pros & Developers. It's quick & easy.

swt and gtk problem

P: n/a
ttn
Hi,

I am using a separately downloaded Eclipse 3M5 on a Debian woody
(stable) system. To make Eclipse start at all I had to use the libgtk2
libraries from some backported gnome 2.2 to get a gtk version >=2.0.6
(now, its 2.2.2).

Now Eclipse runs perfectly (so I have at least one swt app working) as
about any Java application I wrote with it (none using swt).

Now, I want to learn to do stuff with swt and I try to let the
following program run using the swt.jar that came with eclipse:

-----------------------------------------------------------------------
import org.eclipse.swt.widgets.*;

public class Hello {
public static void main(String[] args) {
MessageBox m = new MessageBox(new Shell());
m.setMessage("Hello, World");
m.open();
}
}
-----------------------------------------------------------------------

It compiles good, but as I try to run it, I get the following error:

-----------------------------------------------------------------------
javac -classpath /var/local/java-lib/swt.jar Hello.java
java -classpath /var/local/java-lib/swt.jar:. -D/var/local/java-lib/swt.jar Hello

Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/swt/internal/gtk/OS
at org.eclipse.swt.internal.Converter.wcsToMbcs(Conve rter.java:63)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Conve rter.java:54)
at org.eclipse.swt.widgets.Display.<clinit>(Display.j ava:112)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:23 2)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:22 6)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:18 0)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:11 9)
at Hello.main(Hello.java:5)
-----------------------------------------------------------------------

I suppose there is a problem in finding the right gtk library or
something.

I googled a lot about that but couldn't find anything useful. Any
ideas?

Thankful for help,

TTN
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
javac -classpath /var/local/java-lib/swt.jar Hello.java
java -classpath /var/local/java-lib/swt.jar:. -D/var/local/java-lib/swt.jar Hello


Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/swt/internal/gtk/OS
at org.eclipse.swt.internal.Converter.wcsToMbcs(Conve rter.java:63)
at org.eclipse.swt.internal.Converter.wcsToMbcs(Conve rter.java:54)
at org.eclipse.swt.widgets.Display.<clinit>(Display.j ava:112)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:23 2)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:22 6)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:18 0)
at org.eclipse.swt.widgets.Shell.<init>(Shell.java:11 9)
at Hello.main(Hello.java:5)
-----------------------------------------------------------------------

OK for the first part (putting swt.jar in classpath), but you are
missing that swt-something-something.so (or .dll on windows), SWT needs
it, so the remedy to your problem is adding
-Djava.library.path:/path/where/that/library/file/is or attaching that
path to your LD_LIBRARY_PATH env variable (or PATH on windows).
Cheers!

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.