| Author |
NoClassDefFoundError
|
Ugur Likoglu
Greenhorn
Joined: Jul 20, 2004
Posts: 14
|
|
Hello, I am using Netbeans IDE 3.6 for my test codings, and sometimes I try compiling in the ms-dos command line. My problem is I did compile my code, but I couldn't run it when I wrote java test1. It gives me NoClassDefFoundError although I succesfully applied the classpath configurations before. It was working before, but I couldn't understand what is wrong now. The test1.java, and test1.class is in a seperate folder called test_arrays. May be this is the only difference but I couldn't run it. Thanks a lot. Ugur
|
--ugur<br />"Read,think, and ask. Learn the reason of living."
|
 |
Ryan Smith
Ranch Hand
Joined: Jun 29, 2004
Posts: 40
|
|
Why don't you try putting them in the same folder...see what happens, do a little experimenting...
|
 |
Siva kandasamy
Ranch Hand
Joined: Dec 31, 2002
Posts: 139
|
|
See below. Make sure you . in your classpath. "." represents the current directory. setenv CLASSPATH "/home/siva/rd/java:.:/home/siva/rd/java/com" HTH -siva
|
 |
Ugur Likoglu
Greenhorn
Joined: Jul 20, 2004
Posts: 14
|
|
I did not try to put all the files in the same folder. Because I have to work in different folders. Anyway, what I tried to do is I removed package test1; from the very first beginning of my code, then tried to compile and run again. It worked this time. So there are lots of questions raised in my mind now. Even I removed the line "package test1;" from my code, what happened, then my code executed succesfully? What is the importance of putting "package test1;" at the beginning of the code then? Is there any configuration when you put the "package test1;" at the beginning then to execute the code without any problem? Thanks
|
 |
asif aleem
Greenhorn
Joined: Jul 20, 2004
Posts: 2
|
|
When you are giving package statement in any java file,then that file has to be saved in that in directory name as given for package name, for example package hello; then this source file has to be saved in hello directory.
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
Developers use packages to organize source code, and compiled class files. As asif pointed out, the compiled classes need to be in a directory structure matching the declared packages. In order to use a class such as fubar.Foo, not only does the class Foo need to be in a directory called fubar, but the directory fubar needs to be locatable through the CLASSPATH, so the parent of fubar needs to be in the CLASSPATH. Is this clear, or would you like another example?
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
 |
|
|
subject: NoClassDefFoundError
|
|
|