answersLogoWhite

0

What is classNotFound Exception in java?

Updated: 8/11/2023
User Avatar

Nithyavelumani

Lvl 1
15y ago

Best Answer

If you are getting this error message, it means you are trying to use a class that is not located in your JVM classpath. In order to resolve this error, you must find the .class or the .jar file that contains the class you need, and add it to your classpath.

Depending on the application, it might be as simple as changing your CLASSPATH environment variable. Here is a good article on the Java classpath:

http://en.wikipedia.org/wiki/Classpath_(Java)

Here is a good online utility to help you quickly find the right jar and download it. It will save you hours of searching through various blog posts on the internet trying to find out which jar contains which class file!

http://www.ClassNotFound.com/

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

A classnotfound exception is usually thrown when the JVM cannot locate a particular class.

This usually happens when you are referring to java classes available inside jars. you would have included your jar in the project's build path hence there would be no compile time errors. But when you execute your app, you would've missed to add that jar into the server path. Hence the server is unable to locate the jar and the JVM would throw this exception.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

A class cast exception is thrown by Java when you try to cast an Object of one data type to another.

Java allows us to cast variables of one type to another as long as the casting happens between compatible data types.

For example you can cast a String as an Object and similarly an Object that contains String values can be cast to a String.

Example:

Let us assume we have an HashMap that holds a number of ArrayList objects.

if we write a code like this:

String obj = (String) hmp.get(key);

it would throw a class cast exception because the value returned by the get method of the hash map would be an Array list but we are trying to cast it to a String. This would cause the exception.

This answer is:
User Avatar

User Avatar

Wiki User

15y ago

A ClassNotFoundException normally occurs when you try to run a Java program, but Java can't find your main class. The fix to this problem is to use the -cp command-line flag to set the Java classpath and tell it where your .class files are.

This answer is:
User Avatar

User Avatar

Wiki User

10y ago

You can find information on java lang class not found on many blogs. You can also find information on Stackoverflow and Revisited. This relates to the Java Platform.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is classNotFound Exception in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Is error and exception same?

Error: Any departure from the expected behavior of the system or program, which stops the working of the system is an error. Exception:Any error or problem which one can handle and continue to work normally. Note that in Java a compile time error is normally called an "error," while a runtime error is called an "exception." Errors don't have subclasses while exception has two subclasses, they are compile time exception or checked exception (ClassNotFound Exception, IOException, SQLException etc.) and runtime or unchecked exception(ArrayIndexOutOfBounds Exception, NumberFormat Exception).


How an exception subclass is created in java explain?

We can create a exception sub class by extending Exception class available in java


What is the purpose of NoMatchException handling method in java?

java exception


Which exception is thrown by the add method of Collection interface in java?

exception


What is difference between exception handling in C and Java?

Easy: there is no exception-handling in C.


Which is the base class of exception handling in java?

Thorwable


How do you throw exception in java?

we do it using the throw keyword.


When should we use exception handling in java?

Exception handling should be used in Java in all cases where you as a programmer suspect that your code might throw some exceptions or create errors that might look ugly when a user is using the application. In such cases you use exception handling to catch and handle the exception and exit gracefully. You use the try - catch block in Java for exception handling.


Write the 3 user defined exception in java?

1. Arithmetic Exception 2. Input Output Exception 3. Number Format Exception


What is meant by The Java Software Development Kit?

It is a kit of JAVA development tools that are normally not shipped with JAVA! MOST companies have "Development kits" for their software - Java is not an exception!


What exception thrown by sleep method in java?

InterruptedException is thrown.


Can userdefined exception have two methods in it?

Yes a user defined exception can have any number of methods in it. A user defined exception is nothing but a Java class created for a specific purpose. Just like ordinary Java classes, you can have any number of methods in it...