NoClassDefFoundError when trying to Run... simple SWT widget

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

NoClassDefFoundError when trying to Run... simple SWT widget

Postby william.boger » Tue Mar 16, 2004 7:01 am

:oops: :evil:
Could someone help me ? I know I am close to find the solution, but as I am a newbie to both Java and Eclipse I think I am running in circles around the answer.

I am using Eclipse 2.1.2 on WinXP (couldn't make the 3.0M7 work with SWT-Designer free edition, but that's another problem...)

I can design the widgets and generate code, but I can't make it running outside the design page, i.e. using the "light switch" I can see the shell and associated widgets running, but if i try to do the following:

Run... (by hitting the "running man" icon) I get the following error message:

java.lang.NoClassDefFoundError: de
Exception in thread "main"

This error message comes after launching the JVM.

I've learned in the "Java Tutorial Help file" that this message, in their own words, means the following:
" Error Explanation
If you receive this error, java cannot find your bytecode file, HelloWorldApp.class."

The Java source file is simple as that (just a lousy shell and a simple button code generated by SWT-Designer):

Code: Select all
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
/*  * Created on 16/03/2004  */

/**  * @author William Boger  */
public class It_Works_Main {

public static void main(String[] args) {
   final Display display = new Display();
   final Shell shell = new Shell();
   shell.setLayout(new GridLayout());
   shell.setText("SWT Application");
   {
      final Button button = new Button(shell, SWT.NONE);
      button.setText("button");
   }
   shell.open();
   while (!shell.isDisposed()) {
      if (!display.readAndDispatch())
         display.sleep();
   }
}
}


In the workspace I created the project named "It_Works" (although it doesn't ... :? ), with the files It_Works_Main.java on the "src" sub-folder, whereas It_Works_Main.class is on the "bin" sub-folder.

The ".classpath" file is under {EclipseInstallDirectory}\workspace\It_Works and has the following contents:

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
    <classpathentry exported="true" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.core.boot_2.1.2/boot.jar"/>
    <classpathentry exported="true" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.core.runtime_2.1.1/runtime.jar"/>
    <classpathentry exported="true" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.swt.win32_2.1.2/ws/win32/swt.jar"/>
    <classpathentry exported="true" kind="var" path="ECLIPSE_HOME/plugins/org.eclipse.jface_2.1.1/jface.jar"/>
    <classpathentry kind="output" path="bin"/>
</classpath>


And Yes I have checked the following checkboxes on the "Run..." dialog:
(V) Using default working directory (in Arguments tab)
(V) Use default classpath (in Classpath tab)
(V) Use default Source path look up path (in Source tab)

So what could be going wrong ? Could anyone give me a hint ?

Thanks in advance.
William Boger
IT Consultant - Developer (Brazil)
william.boger
 
Posts: 1
Joined: Tue Mar 16, 2004 6:25 am
Location: Brazil

Postby raphael » Tue Mar 16, 2004 7:44 am

well, your code works fine for me. Are you able to run a normal java program?
raphael
 
Posts: 22
Joined: Thu Jan 29, 2004 3:41 pm

Re: NoClassDefFoundError when trying to Run... simple SWT wi

Postby Eric Clayberg » Tue Mar 16, 2004 2:08 pm

william.boger wrote:So what could be going wrong ? Could anyone give me a hint ?

I tried your code and it works fine for me as well. Do you have the SWT DLL on your path (as specified in the SWT Designer docs and tutorial)? That is the most common reason that an SWT class won't run.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest