Newbie SWT Setup Problem: ClassDefNotFoundError [message #373057] |
Sat, 30 August 2003 05:30 |
Eclipse User |
|
|
|
Originally posted by: gbelchitt.donotreply.org
Hello, I am trying to get going with SWT so I can try out GTK2 with
Java. I'm running Debian Linux unstable and have installed the
eclipse-platform and libswt2.1-gtk2-java packages. The file I am trying
to compile is from a PDF tutorial document:
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.*;
public class SWTHello {
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
Label label = new Label(shell, SWT.NONE);
label.setText("Hello World");
shell.pack();
label.pack();
shell.open();
while(!shell.isDisposed())
if(!display.readAndDispatch())
display.sleep();
display.dispose();
label.dispose();
}
}
and it compiles perfectly fine, but when I run it I get:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/swt/internal/gtk/OS
at org.eclipse.swt.widgets.Display.createDisplay(Display.java:4 82)
at org.eclipse.swt.widgets.Display.create(Display.java:469)
at org.eclipse.swt.graphics.Device.<init>(Device.java:111)
at org.eclipse.swt.widgets.Display.<init>(Display.java:303)
at org.eclipse.swt.widgets.Display.<init>(Display.java:299)
at SWTHello.main(SWTHello.java:7)
I think this could be a problem with me not having the CLASSPATH set
right, or something about LD_LIBRARY_PATH ?? here are my variable
settings now:
CLASSPATH=.:/usr/local/j2sdk1.4.1_02/lib:/usr/local/j2sdk1.4 .1_02/jre/lib:/usr/share/java:/usr/share/eclipse/plugins/org .eclipse.swt.gtk_2.1.1/ws/gtk/swt.jar
LD_LIBRARY_PATH=/usr/lib/eclipse
What am I doing wrong?
Thank you!
|
|
|
Re: Newbie SWT Setup Problem: ClassDefNotFoundError [message #373058 is a reply to message #373057] |
Sat, 30 August 2003 10:19 |
Eclipse User |
|
|
|
Originally posted by: muelleimer.usenet.katzien.de
Hallo!
* George Belchitt <gbelchitt@donotreply.org> wrote:
> Hello, I am trying to get going with SWT so I can try out GTK2 with
> Java. I'm running Debian Linux unstable and have installed the
> eclipse-platform and libswt2.1-gtk2-java packages. The file I am trying
> to compile is from a PDF tutorial document:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/eclipse/swt/internal/gtk/OS
The PI jar isn't in the classpath.
> CLASSPATH=.:/usr/local/j2sdk1.4.1_02/lib:/usr/local/j2sdk1.4 .1_02/jre/lib:
>/usr/share/java:
Hm, I'm not sure. how good that is, as there are motif and gtk version
in there (if installed). But actually it should pick up the pi jar
from there.
Actually my java refused to load the class from there (if only the dir
is specified).
> /usr/share/eclipse/plugins/org.eclipse.swt.gtk_2.1.1/ws/gtk/ swt.jar
The prefered way to do that under debian linux (after the -4 version
of eclipse, there is a bug in -3) is:
(sh mode)
source /usr/share/eclipse/ws/libswt2.1-gtk2-java.jars
javac -classpath $JARS Main.java
java -Djava.library.path=/usr/lib/jni -classpath $JARS:. Main
Please note, that there is an error in the libswt2.1-gtk2-java.jars
file, so that the pi jar isn't added. You have to correct that by hand
or wait for the next version (-4 has it fixed).
Also, ther might be a change in this mechnism. I'm currently proposing
to include such a mechanism for all java libs in debian.
Jan, debian eclipse maintainer
|
|
|
Re: Newbie SWT Setup Problem: ClassDefNotFoundError [message #373059 is a reply to message #373058] |
Sat, 30 August 2003 15:14 |
Eclipse User |
|
|
|
Originally posted by: gbelchitt.donotreply.org
Jan,
Thank you! I placed both swt.jar AND swt-pi.jar into my CLASSPATH and
all works well now. I'm looking forward to moving beyond Hello World now :-)
Jan Schulz wrote:
> Hallo!
>
> * George Belchitt <gbelchitt@donotreply.org> wrote:
>
>>Hello, I am trying to get going with SWT so I can try out GTK2 with
>>Java. I'm running Debian Linux unstable and have installed the
>>eclipse-platform and libswt2.1-gtk2-java packages. The file I am trying
>>to compile is from a PDF tutorial document:
>>Exception in thread "main" java.lang.NoClassDefFoundError:
>>org/eclipse/swt/internal/gtk/OS
>
>
> The PI jar isn't in the classpath.
>
>
>> CLASSPATH=.:/usr/local/j2sdk1.4.1_02/lib:/usr/local/j2sdk1.4 .1_02/jre/lib:
>>/usr/share/java:
>
>
> Hm, I'm not sure. how good that is, as there are motif and gtk version
> in there (if installed). But actually it should pick up the pi jar
> from there.
>
> Actually my java refused to load the class from there (if only the dir
> is specified).
>
>
>> /usr/share/eclipse/plugins/org.eclipse.swt.gtk_2.1.1/ws/gtk/ swt.jar
>
>
> The prefered way to do that under debian linux (after the -4 version
> of eclipse, there is a bug in -3) is:
> (sh mode)
> source /usr/share/eclipse/ws/libswt2.1-gtk2-java.jars
> javac -classpath $JARS Main.java
> java -Djava.library.path=/usr/lib/jni -classpath $JARS:. Main
>
> Please note, that there is an error in the libswt2.1-gtk2-java.jars
> file, so that the pi jar isn't added. You have to correct that by hand
> or wait for the next version (-4 has it fixed).
>
> Also, ther might be a change in this mechnism. I'm currently proposing
> to include such a mechanism for all java libs in debian.
>
> Jan, debian eclipse maintainer
|
|
|
Re: Newbie SWT Setup Problem: ClassDefNotFoundError [message #373061 is a reply to message #373057] |
Sat, 30 August 2003 10:00 |
Eclipse User |
|
|
|
Originally posted by: simon.rutishauser.gmx.ch
....
> CLASSPATH=.:/usr/local/j2sdk1.4.1_02/lib:/usr/local/j2sdk1.4 .1_02/jre/lib:/usr/share/java:/usr/share/eclipse/plugins/org .eclipse.swt.gtk_2.1.1/ws/gtk/swt.jar
....
Quite right except for that your CLASSPATH is missing the swt-pi.jar file.
This file is GTK2-Platform-Only and therefore not mentioned in all docs I
guess. But it is just as necessary in your CLASSPATH as swt.jar
Peschmä
|
|
|
Re: Newbie SWT Setup Problem: ClassDefNotFoundError [message #373066 is a reply to message #373061] |
Sat, 30 August 2003 18:22 |
Eclipse User |
|
|
|
Originally posted by: muelleimer.usenet.katzien.de
Hallo!
* Simon Rutishauser <simon.rutishauser@gmx.ch> wrote:
>> CLASSPATH=[...]:/usr/share/java:[swt.jar]
> Quite right except for that your CLASSPATH is missing the swt-pi.jar file.
> This file is GTK2-Platform-Only and therefore not mentioned in all docs I
> guess. But it is just as necessary in your CLASSPATH as swt.jar
It should be in /usr/share/java as
/usr/share/java/swt2.1-gtk.jar
/usr/share/java/swt-pi2.1-gtk.jar
, so AFAI understod this, the 'java -cp /usr/share/java:.' should have
been enough. It doesn't work with my BD java, though...
Jan, never mind...
|
|
|
Re: Newbie SWT Setup Problem: ClassDefNotFoundError [message #373067 is a reply to message #373059] |
Sat, 30 August 2003 18:32 |
Eclipse User |
|
|
|
Originally posted by: muelleimer.usenet.katzien.de
Hallo!
* George Belchitt <gbelchitt@donotreply.org> wrote:
> Jan,
> Thank you! I placed both swt.jar AND swt-pi.jar into my CLASSPATH and
> all works well now. I'm looking forward to moving beyond Hello World now :-)
>> source /usr/share/eclipse/ws/libswt2.1-gtk2-java.jars
>> javac -classpath $JARS Main.java
>> java -Djava.library.path=/usr/lib/jni -classpath $JARS:. Main
Please note, that this approach will work, even when there is a 2.1.2
version of eclipse debian packages. Referencing the SWT jars from
/usr/share/eclipse/... will not, if eclipse.org chooses to pump up the
swt plugin version.
You can also switch to the motif version by
source /usr/share/eclipse/ws/libswt2.1-motif-java.jars
....
Jan
|
|
|
Powered by
FUDForum. Page generated in 0.02890 seconds