Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[platform-swt-dev] java.lang.NoClassDefFoundError when running a standalone SWT application

Hi all,

Anyone can help me in trouble of facing "java.lang.NoClassDefFoundError"
when trying to excuse a standalone SWT application complied on the
environment of SWT ver 2.13 and j2sdk1.4.2_04, taking following steps,

1) dir

 C:\j2sdk1.4.2_04\work
2004/07/03  09:52       <DIR>          .
2004/07/03  09:52       <DIR>          ..
2004/03/11  04:17              278,528 swt-win32-2136.dll
2004/03/11  04:17            1,019,114 swt.jar
2004/06/29  21:52                  455 WindowSample1.BAK
2004/07/03  09:52                  699 WindowSample1.class
2004/07/03  09:50                  431 WindowSample1.java



2) Compiling from DOS command prompt of Windows 2000

C:\j2sdk1.4.2_04\work>javac -classpath swt.jar WindowSample1.java



3) Executing from DOS command

C:\j2sdk1.4.2_04\work>java -classpath swt.jar WindowSample1
Exception in thread "main" java.lang.NoClassDefFoundError: WindowSample1

C:\j2sdk1.4.2_04\work>java WindowSample1
Exception in thread "main" java.lang.NoClassDefFoundError:
org/eclipse/swt/widge
ts/Display
        at WindowSample1.main(WindowSample1.java:6)


4) Source code of a sample program using swt

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

public class WindowSample1 {
  public static void main (String [] args) {
    Display display = new Display ();
    Shell shell = new Shell(display);
    shell.setText("Window Sample1");
    shell.setSize(200,100);
    shell.open();
    while (!shell.isDisposed ()){
      if (!display.readAndDispatch ()){
        display.sleep ();
      }
    }
    display.dispose ();
  }
}
------------------------------------------------------------



Back to the top