This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
past one time same error occured for me when i run java it shown Exception in thread "main" java.lang.NoClassDefFoundError:Test. just set class path after compile the java appl. like d:set CLASSPATH=D:\ d:java test your program should run...! happy.... regard, Vinu-Chennai
That exception occurs if you don't have a file called Test.class accessible. Most common reason: navigating to the wrong folder.
You ought to have .; or ;. or ;.; in your CLASSPATH system environment variable on Windows and 99% or Windows installations have the . in there somewhere by default. Did you have a package declaration in your Test.java class? (You probably didn't, but that would move the Test.class file into a different folder.) Use the "dir" command to find whether you have got Test.class in the folder you have navigated to in the command prompt.
Use a similar technique to setting up the PATH to make sure there is a . in the CLASSPATH. There is probably a simpler way to view the CLASSPATH, maybe you write "classpath" but I can't remember what it is.
Hope you get your problem sorted soon
Joined: Oct 13, 2005
Originally posted by myself: That exception occurs if you don't have a file called Test.class accessible. . . .
It seems a silly question, but please confirm that your Test.java file compiled successfully.
Joined: Oct 13, 2005
Oh, I am sorry, I hadn't noticed you are on Linux; on Linux you don't need a CLASSPATH at all, as long as you have navigated your shell to the correct folder with the cd command.
If you receive this error, java cannot find your compiled byte code file, HelloWorld.class.If both your class files and source code are in the same working directory and if you try running your program from the current working directory than, your program must get executed without any problems as, java tries to find your .class file is your current directory. If your class files are present in some other directory other than that of the java files we must set the CLASSPATH pointing to the directory that contain your compiled class files.CLASSPATH can be set as follows on a Windows machine:
a. Click Start > Right Click "My Computer" and click on "Properties" b. Click Advanced > Environment Variables. in the user variable->click new or edit then give variable name as CLASSPATH.and value as location of your .class file eg.your class is in D' means give D:\
Add the location of classes� folder containing all your java classes in User Variables.
If there are already some entries in the CLASSPATH variable then you must add a semicolon and then add the new value . The new class path takes effect in each new command prompt window you open after setting the CLASSPATH variable. thats all... Vinoth-KRm
And your advice to alter the CLASSPATH on Windows is quite unnecessary. As long as there is .; ;. or ;.; in the CLASSPATH it will work. In fact you shouldn't normally change the system CLASSPATH at all.
I get the class not found exception evrey time I try to run the even a simple hello wqorld program.Although my .class file got created i.e. It compiled the code succesfully but culd not run it.I have set classpath and other enevronment var proprly.I have neatbeans installed on my systems,Is that create a prolbem programmes running with the command prompt?/!!
I tried unstall and then reinstall too.
please help me out with the problwm, because I tired thinking about this strange thing.
The naming policy has already been brought to your notice multiple times before. It is strongly recommended that you take it seriously. You are expected to adjust your display name to comply to the naming policy before posting anything. Please note, this is not optional and naming violators stand a chance of getting their account suspended.