Howdy (I've always wanted to say that (and mean it) from some strange reason), I'de first like to say that this site is awsome, I love the theme and with all these java experts around, I am wondering if I can hang my hat for a little while (ok, enough with the silliness(SP?), I am aware that it can annoy some grumpy folks after a while :-)). Ok, down to business. I have the JDK 5.0 release 7 and I have it installed in just one folder away from my lettered drive on Windows XP, for example; (F:\Java). When I edit source code through a text editor and then compile it through the terminal it seems to compile fine and I get a pretty little class file afterwords. However, the trouble comes when I try and run the program with the 'java' command. I get a weird error? message. It reads as follows:
Of course in this example I used helloWorld as the name of the class that I was trying to run. It's not the code, at least I don't think so because my Mac runs the same code on the same JDK (just a different release, release 5) perfectly. This is not just isolated to one incedent either, it happens every time. Because of my problem (well not the entire reason, I love eclipse), I am using eclipse and ofcourse with eclipse, everything works perfectly but it just erks me that I can't run my classes/apps from the terminal on my wondows machine. I also have a windows laptop but I am affraid to edit the path variables on that machine as well for fear that I might screw it up in the same way. I am new to the Windows Environment, having come back to windows because of .NET around a year ago but other than that I am used to *nix platforms such as Linux and OS X so my knowledge of windows is slim. Does anyone know what's wrong? I tried to look up: java.lang.NoClassDefFoundError in Java in a Nutshell (latest edition) and I can't seem to find anything about it, as if it doesn't exsist? Please excuse my ignorance, I am brand spanking new to Java but not to programming (some C (old school, lol I'm 25y/o, what am I doing talking about old school?), .NET, Python and ActionScript) If anyone could help, I would be very greatful and extremely happy. (I'll have my itch scatched, you know the one the is starting to sting a little.) No really, I would be very greatful for a fix to my seemingly small but notoriously big problem. Thanks in advance You can contact me through this e-mail. firstname.lastname@example.org
Try typing in "NoClassDefFoundError" in Google. You'll find that it's one of the pitfalls that almost all new Java programmers hit.
In addition to that, in my signature (below this message) there is a link to The Java Tutorial. It's a very useful online tutorial, and the "Hello World" example there explains exactly what this error means and what you have to do about it.
Thanks guys, Keith, so my workspace (whichever that may be) has to be named in my CLASSPATH?
Jesper, I am still going through the links in your signature. I still havent found anything on the issue at hand (but I have just looked through briefly.) I got it to work by putting my workspace or the folder containing my source and class file in my CLASSPATH variable, However, I had to delete the the package name in the source file in order for it to work.