NoClassDefFoundError:
Reasons
- This error would occur if you execute the program with a modified classname. consider for eg. Let the name of the program be Example.java and if u compile and execute the program as follows
- javac Example.java
- java example
2. Whenever a java program is compiled it creates a class file.This class file is used to launch the program.We all know about the variable classpath.The classpath lists all directories and archive files which are all starting points for locating classes.
So when a program is to be executed jvm will look for the class file(of the program) in the path specified in the variable CLASSPATH.
If the class is not available in the path specified by the CLASSPATH variable then this error would appear.
Correction
1.This error can be resolved by eliminating the accidental mistyping of the classname during launching.
2.If the CLASSPATH variable is modified to include the class file then this error can be avoided.
Note:
Note:
- The CLASSPATH can be set to multiple values each separated by semi colon as follows
java -classpath c:\classdir;.;c:\archives\archive.jar Example.
- The CLASSPATH can also be made to point to the current location by using the dot(.) as follows.
java -classpath .; Example
- If a class file belongs to a jar then the jar must be added to the CLASSPATH variable.
1 comments:
JMS Training Institutes in Chennai | JSP Training Institutes in Chennai | Java Spring Hibernate Training Institutes in Chennai | EJB Training Institutes in Chennai | Hibernate Training Institutes in Chennai |
JSF Training Institutes in Chennai | Java EE Training Institutes in Chennai | J2EE Training Institutes in Chennai | Core Java Training Institutes in Chennai | Java Training Institutes
| Struts2 Training Institutes in Chennai | Spring Training Institutes in Chennai
Post a Comment