why should we get the following error ?
Exception in main method NoClassDefFoundError:classname

could anyone give the detail clarification on how java
compiler can look for .class file?

Answer Posted / hardik

In most gnral mistech one make is file name and class name
error than this error accurs mostly , or no classname found
when the environment variable or class path is not given

Java compilor search for the path given to the class name
(ig in cmd javac searching in same folder if we have given
path = ./) .class files than java command searchs for the
same path but if it is not given to the same this error
comes. and java compilor never looks for the class file it
looks for the the .java file and it creates .class file
which than looked by java run time environment.

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can extern variables be initialized?

509


How a string is stored in memory?

577


What design pattern you have used in your project? I answered Factory pattern, how it is implemented? What are its advantage? Do know about Abstract Factory?

1932


Explain wait(), notify() and notifyall() methods of object class ?

592


Can a class have 2 constructors?

498






What is java life cycle?

535


Can you inherit from an abstract class java?

525


What is a vararg?

548


Can we use a switch statement with strings?

549


What are the advantages of exception handling?

551


What is function declaration?

525


What is static block?

587


what is thread in Java ?

622


What are implicit objects in java?

549


Can you override a final method?

578