File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes can't compile ANYWHERE... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "can Watch "can New topic

can't compile ANYWHERE...

Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
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 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?

Help! I'm pathetic!

Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
BTW - I *know* this has to do w/ the CLASSPATH env. variable but no matter *how* I set the stupid thing, it won't work.

I did this, just to test.

Setup the classpath variable to point to "c:\java_bin", a dir. I created myself.

I put which contains this code, in that dir.

...compiled it, then tried to run via command-line and I get this error STILL:

Exception in thread "main" java.lang.NoClassDefFoundError: MyClass/class

What gives?

Can a moderator perhaps move this to another topic that would get the proper attention? I started here because I started w/ a SWT app that had this same problem but now I can't get *anything* to run.

Petr Blahos
Ranch Hand

Joined: Apr 28, 2004
Posts: 131
Hi Vinnie,

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) ;-)

Best regards, Petr

Get a better web browser:<br /><a href="" target="_blank" rel="nofollow"></a>
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
Vinnie, have you tried putting a . in the classpath, this will tell Java to look in the current directory for the class.

e.g. something like "C:\stuff\;.;"

SCJP 1.4,
Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
Yes, I actually started another thread in the beginners forum, see here for where I'm at currently, still having absolutely no luck even running the simplest of java apps.
Boris Benda

Joined: Aug 31, 2004
Posts: 3
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.
I agree. Here's the link:
subject: can't compile ANYWHERE...
It's not a secret anymore!