Java could not find or load main class?
Last updated on
I am getting following error using IntellJ IDE...
Error: Could not find or load main class AddressCalc Caused by: java.lang.NoClassDefFoundError: AddressCalc (wrong name: AddressCal)
Caused by: java.lang.NoClassDefFoundError: AddressCalc (wrong name: AddressCal)
Share your thoughts
Check the class you are trying to run...
If your class is HelloWorld and you run:
then you will have issues.
Also make sure you are running the class from the right parent directory. Also make sure the class path is defined correctly..
Brenda Becker |
This can happen for several reasons. Not to be mean but the error clearly states the obvious here. The problem is most Java developers don't learn about the class loading mechanism..
This class loading mechanism is "automagically" used by the JRE to identify unique classes and load them into memory.
The JRE utilizes a native operation to load bootstrapped classes. It then uses ClassLoader to locate and cache classes as they are dynamically used by the application.
So you probably aren't naming your class right or using the wrong extension, because Java just plain and simple can't find the class...