I'm a absolute n00b, no shame here... I'm a long-time C#/.NET developer who's transitioning to Java as a primary technology and I'm having a serious issue getting *anything* to compile on *any* platform!
I get this error, "java.lang.NoClassDefFoundError" on my "Hello World" test SWT app in Eclipse. The thing is, I also get this same error when using eclipse on my Gentoo Linux machine or this here WinXP box...so I must be doing something that's typically lame and just don't know it.
Here's my SWT code (Eclipse on WinXP) giving me the error:
Here's the full error eclipse shows me:
I can do a simple command-line hello world and get the same error on Windows and Linux, like I said, so this must be an eclipse thing?
I've tried compiling a simple Hello World CLI app and I get the same error, so maybe it's not just an Eclipse issue?
To your second post: try declaring your class as public. Apart from that, you don't have to set the classpath if you do not use any extra classes and the class being run is in the current directory.
Now, with this SWT: I have never used it so I am just guessing. As it is not a core part of java you have to add it to class path. I don't use eclipse so I can't tell where you can do it.
Just a suggestion: If you have just started learning why don't you try Swing? I am not saying that it's better than SWT but it is a core part of java and apparently it is easier to cope with just 50 new things than 51 (50 + classpath) ;-)
Try this: Right click on your project and choose Java Build Path. Then click on Libraries tab and there you will find "Add External JARs" - click on it. Now you have to find swt.jar file which is located in <folder where you've installed eclipse>\plugins\org.eclipse.swt.win32_3.0.0\ws\win32 ( it's C:\Program Files\eclipse3.0final\\plugins\org.eclipse.swt.win32_3.0.0\ws\win32 in my case ). Now go Run>Run.. and click New. Now click on Arguments tab and in VM argument write:-Djava.library.path="<folder where you've installed eclipse>\eclipse3.0final\plugins\org.eclipse.swt.win32_3.0.0\os\win32\x86" ( it's -Djava.library.path="C:\Program Files\eclipse3.0final\plugins\org.eclipse.swt.win32_3.0.0\os\win32\x86" in my case ). Click Run and enjoy.