How do I resolve this Java Class not found exception?

How do I resolve this Java Class not found exception?

Hi,

Many time new developer faces the Class not found exception. Why it happens and how to resolve this?

Thanks

View Answers

April 24, 2017 at 11:58 PM

Hi,

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:

Book.java

and

Author.java

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.

Thanks









Related Tutorials/Questions & Answers:
How do I resolve this Java Class not found exception?
How do I decompile Java class files?
Advertisements
what are the jar files should i add to resolve the Exception(Class org.apache.jsp.index_jsp Not Found) ?
How do I initialize a byte array in Java?
How do I compare strings in Java?
How do i do the coding for 'leaving a comment' in java
How do I do this program? I'm new to Java programming...
how do i write a java program for this??
How to found which class or method contain specific annotation?
How do I set environment variables from Java?
How do I write a correct micro-benchmark in Java?
How do I throw a 404 error from within a java servlet?
How do I upgrade mysql?
How do i create the node for target SMO in java..???
How do I handle the reaction of a circle and a semi-circle colliding in java?
How do i start to create Download Manager in Java - JSP-Servlet
how to resolve the problem like when i extract the struts-blank-1.3.10.war it shows java .io.filenotfound
How do I sort by mutiple columns that are in ArrayList using some comparable class
How do I read a large file quickly in Java?
How can I do it? .click();
my hibernate showing the following exception so how i can resolve it
how do i solve this problem?
how do i solve this question?
How do I learn Java programming in one day from zero?
How do I learn Java programming in one day from zero?
How do I study big data?
How do I generate random number?
I developed a simple java web project in Struts now If I have to import the project in Eclipse Indigo how can I do it
How do you call a constructor for a parent class?
How do I learn Spring Framework?
How do I learn Spring Framework?
How do I learn Spring Framework?
How do I learn Spring Framework?
How do I learn Spring Framework?
How do I compile the registration form?
How do I get started with Bootstrap
How do I get started with Bootstrap
Error:No Class Found Exception:org.postgresql.driver
class not found exception
PureStack question---i dont know how to do this
PureStack question---i dont know how to do this
how do i begin a two dimensional array?
How do I choose a data science course?
CLASS NOT FOUND EXCEPTION
How do I start machine learning with Python? What should I do if I am a beginner?
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
HOW TO I CHANGE THE SWITCH TO IF ELSE OR DO WHILE OR WHILE DO FOR THIS CODING
How do I use JGraph to create a MST(minimum spanning tree) using java?

Ads