• Post Reply Bookmark Topic Watch Topic
  • New Topic

NoClassDefFoundError  RSS feed

 
Ugur Likoglu
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Ryan Smith
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you try putting them in the same folder...see what happens, do a little experimenting...
 
Siva kandasamy
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!