How do I resolve this Java Class not found exception?

Ads
 

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

Ads









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 write a java program for this??
How do I do this program? I'm new to Java programming...
how to resolve the problem like when i extract the struts-blank-1.3.10.war it shows java .io.filenotfound
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 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 do I read a large file quickly in Java?
How do I upgrade mysql?
my hibernate showing the following exception so how i can resolve it
How to found which class or method contain specific annotation?
How can I do it? .click();
How do I sort by mutiple columns that are in ArrayList using some comparable class
how do i solve this problem?
how do i solve this question?
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 I generate random number?
How do I study big data?
How do I use JGraph to create a MST(minimum spanning tree) using java?
How do I learn Spring Framework?
How do I learn Spring Framework?
How do you call a constructor for a parent class?
How do I compile the registration form?

Ads