Many time new developer faces the Class not found exception. Why it happens and how to resolve this?
The main reason of this exception is un-availability of the dependent file used in the program.
For example you have two classes in a project:
You are using the object of Author.java in Book.java. You have compiled these files together and copied to some other place for running the code.
But while copying Author.class is not copied or copied at wrong directory.
When you try to run the Book.class then it wont run and throw java.lang.ClassNotFoundException for Author.class.
If you again copy Book.class and Author.class in the same directory it will start working.
Above description is for the beginner programmer. For expert programmer if such error comes in your project then the most possible reason would be un-availability of dependent library in the project.
You should include all the required jar files in your project for running application correctly.
If you are using maven then its very easy to use the maven dependency and you add it in few lines of code.